Dozer(v. 5.3.2) は int 型を Boolean(Wrapper) 型にマッピングできますか?
1976 次
4 に答える
3
ドキュメンテーションをざっと読んだだけで、 custom を介してほとんどすべてのものを何にでもマップできるBeanMapping
ので、... 「はい」
于 2013-01-02T12:39:18.583 に答える
1
public class NewDozerConverter
extends DozerConverter<Integer, Boolean> {
public NewDozerConverter() {
super(Integer.class, Boolean.class);
}
public Boolean convertTo(Integer source, Boolean destination) {
if (source > 1) {
return Boolean.TRUE;
} else if (source < 0) {
return Boolean.FALSE;
}
throw new IllegalStateException("Unknown value!");
}
public Integer convertFrom(Boolean source, Integer destination) {
if (Boolean.TRUE.equals(source)) {
return 1;
} else if (Boolean.FALSE.equals(source)) {
return 0;
}
throw new IllegalStateException("Unknown value!");
}
}
于 2013-01-02T12:48:03.563 に答える
1
はい....int型をBooleanまたはその他のデータ型にマップできます。この種のマッピングには、カスタム コンバーターが必要です
于 2013-01-02T12:41:29.330 に答える