use of io.atlasmap.java.v2.JavaEnumField in project atlasmap by atlasmap.
the class TargetValueConverter method resolveTargetSetMethod.
private Method resolveTargetSetMethod(Object sourceObject, Field field, Class<?> targetType) throws AtlasException {
AtlasPath atlasPath = new AtlasPath(field.getPath());
Object parentObject = sourceObject;
List<Class<?>> classTree = resolveMappableClasses(parentObject.getClass());
if (field instanceof JavaField) {
JavaField javaField = (JavaField) field;
for (Class<?> clazz : classTree) {
try {
String setterMethodName = javaField.getSetMethod();
if (setterMethodName == null) {
setterMethodName = "set" + capitalizeFirstLetter(atlasPath.getLastSegment());
}
return ClassHelper.detectSetterMethod(clazz, setterMethodName, targetType);
} catch (NoSuchMethodException e) {
// method does not exist
}
// Try the boxUnboxed version
if (conversionService.isPrimitive(targetType) || conversionService.isBoxedPrimitive(targetType)) {
try {
String setterMethodName = javaField.getSetMethod();
if (setterMethodName == null) {
setterMethodName = "set" + capitalizeFirstLetter(atlasPath.getLastSegment());
}
return ClassHelper.detectSetterMethod(clazz, setterMethodName, conversionService.boxOrUnboxPrimitive(targetType));
} catch (NoSuchMethodException e) {
// method does not exist
}
}
}
} else if (field instanceof JavaEnumField) {
for (Class<?> clazz : classTree) {
try {
String setterMethodName = "set" + capitalizeFirstLetter(atlasPath.getLastSegment());
return ClassHelper.detectSetterMethod(clazz, setterMethodName, targetType);
} catch (NoSuchMethodException e) {
// method does not exist
}
}
}
throw new AtlasException(String.format("Unable to resolve setter for path=%s", field.getPath()));
}
use of io.atlasmap.java.v2.JavaEnumField in project atlasmap by atlasmap.
the class BaseDocumentWriterTest method createEnumField.
public JavaEnumField createEnumField(String path, Enum<?> value) {
JavaEnumField f = new JavaEnumField();
f.setPath(path);
f.setName(value.name());
f.setOrdinal(value.ordinal());
f.setFieldType(FieldType.NONE);
f.setValue(value);
return f;
}
Aggregations