Dozerをセットアップして、2つのエンティティ間で複雑なマッピングを実行しようとしています。基本的には、値が1(100%)であるかどうかに基づいて、私のpercentCompleted
doubleをブール値に変換したいと思います。Javaがローカルクラスを見つけられないと不平を言うのはなぜですか?
private void initEntityMappings()
{
BeanMappingBuilder builder = new BeanMappingBuilder() {
@Override
protected void configure() {
class isCompletedConverter implements CustomConverter {
@Override
public Object convert(Object destination, Object source, Class destClass, Class sourceClass) {
if (source == null) { return null; }
// Make sure the source is a double and the destination is a boolean
if (!(source instanceof Double) || !(destination instanceof Boolean))
throw new MappingException("Source was not a double or destination was not a boolean");
Boolean castedDest = (Boolean)destination;
Double castedSrc = (Double)source;
castedDest = castedSrc == 1;
return castedDest;
}
};
mapping(TaskDetailsViewModel.class, TaskSummaryViewModel.class)
.fields("percentCompleted", "isCompleted", customConverter(isCompletedConverter));
}
};
}
問題は、それがisCompletedConverter
のシンボルを見つけることができないと言うので、それは.fields()
通話が文句ということです:
ああ、 'isCompletedConverter.class'がうまくいきましたが、今はなぜか分かりました。 Javaのコンベンションでの良い呼び出し。 – KallDrexx