You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@SneakyThrows
public static Map<String, Object> toMap (@NonNull Object object) {
val result = new HashMap<String, Object>();
val type = object.getClass();
val setAccessibleAction = new SetAccessibleAction();
for (val field : type.getDeclaredFields()) {
val modifiers = field.getModifiers();
if (isFinal(modifiers) || isStatic(modifiers)) {
continue;
}
setAccessibleAction.setField(field);
AccessController.doPrivileged(setAccessibleAction);
val fieldValue = field.get(object);
if (fieldValue == null) {
continue;
}
val propertyKey = field.isAnnotationPresent(FormProperty.class)
? field.getAnnotation(FormProperty.class).value()
: field.getName();
result.put(propertyKey, fieldValue);
}
return result;
}
This means we can't use data classes in Kotlin. Is there a compelling reason why final fields are being ignored?
Final fields are ignored in PojoUtils.toMap:
This means we can't use data classes in Kotlin. Is there a compelling reason why final fields are being ignored?