public long getProblemScale(Solution solution) {
long problemScale = 0L;
for (PropertyAccessor entityPropertyAccessor : entityPropertyAccessorMap.values()) {
Object entity = extractEntity(entityPropertyAccessor, solution);
if (entity != null) {
EntityDescriptor entityDescriptor = findEntityDescriptorOrFail(entity.getClass());
problemScale += entityDescriptor.getProblemScale(solution, entity);
}
}
for (PropertyAccessor entityCollectionPropertyAccessor : entityCollectionPropertyAccessorMap.values()) {
Collection<?> entityCollection = extractEntityCollection(
entityCollectionPropertyAccessor, solution);
for (Object entity : entityCollection) {
EntityDescriptor entityDescriptor = findEntityDescriptorOrFail(entity.getClass());
problemScale += entityDescriptor.getProblemScale(solution, entity);
}
}
return problemScale;
}