두 엔티티간에 복잡한 매핑을 수행하도록 Dozer를 설정하려고합니다. 기본적으로 값이 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'가 효과가 있었고 이제는 왜 그럴까요. 자바 관례에 또한 좋은 외침. – KallDrexx