Java Code Examples for org.jpmml.model.ReflectionUtil#getFields()
The following examples show how to use
org.jpmml.model.ReflectionUtil#getFields() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArrayListTransformer.java From jpmml-model with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public VisitorAction visit(PMMLObject object){ List<Field> fields = ReflectionUtil.getFields(object.getClass()); for(Field field : fields){ Object value = ReflectionUtil.getFieldValue(field, object); if((value instanceof ArrayList) && (value.getClass()).equals(ArrayList.class)){ ArrayList<?> list = (ArrayList<?>)value; List<?> transformedList = transform(list); if(list != transformedList){ ReflectionUtil.setFieldValue(field, object, transformedList); } } } return super.visit(object); }
Example 2
Source File: ArrayListTrimmer.java From jpmml-model with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public VisitorAction visit(PMMLObject object){ List<Field> fields = ReflectionUtil.getFields(object.getClass()); for(Field field : fields){ Object value = ReflectionUtil.getFieldValue(field, object); if(value instanceof ArrayList){ ArrayList<?> list = (ArrayList<?>)value; list.trimToSize(); } } return super.visit(object); }
Example 3
Source File: Interner.java From jpmml-model with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public VisitorAction visit(PMMLObject object){ Class<? extends V> type = getType(); List<Field> fields = ReflectionUtil.getFields(object.getClass()); for(Field field : fields){ Object value = ReflectionUtil.getFieldValue(field, object); if(type.isInstance(value)){ V internedValue = intern(type.cast(value)); ReflectionUtil.setFieldValue(field, object, internedValue); } } return super.visit(object); }
Example 4
Source File: FieldNameFilterer.java From jpmml-model with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public VisitorAction visit(PMMLObject object){ List<Field> fields = ReflectionUtil.getFields(object.getClass()); for(Field field : fields){ if((FieldName.class).equals(field.getType())){ FieldName name = (FieldName)ReflectionUtil.getFieldValue(field, object); name = filter(name); ReflectionUtil.setFieldValue(field, object, name); } } return super.visit(object); }
Example 5
Source File: VersionInspector.java From jpmml-model with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public VisitorAction visit(PMMLObject object){ for(Class<?> clazz = object.getClass(); clazz != null; clazz = clazz.getSuperclass()){ inspect(clazz); } List<Field> fields = ReflectionUtil.getFields(object.getClass()); for(Field field : fields){ Object value = ReflectionUtil.getFieldValue(field, object); inspect(field, value); // The field is set to an enum constant if(value instanceof Enum){ Enum<?> enumValue = (Enum<?>)value; Field enumField; try { Class<?> enumClazz = enumValue.getClass(); enumField = enumClazz.getField(enumValue.name()); } catch(NoSuchFieldException nsfe){ throw new RuntimeException(nsfe); } inspect(enumField); } } return super.visit(object); }
Example 6
Source File: InvalidMarkupInspector.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 5 votes |
@Override public VisitorAction visit(PMMLObject object){ List<Field> fields = ReflectionUtil.getFields(object.getClass()); for(Field field : fields){ Object value = ReflectionUtil.getFieldValue(field, object); if(value instanceof List){ List<?> collection = (List<?>)value; // The getter method may have initialized the field with an empty ArrayList instance if(collection.isEmpty()){ value = null; } } // End if // The field is set if(value != null){ continue; } XmlElement element = field.getAnnotation(XmlElement.class); if(element != null && element.required()){ report(new MissingElementException(object, field)); } XmlAttribute attribute = field.getAnnotation(XmlAttribute.class); if(attribute != null && attribute.required()){ report(new MissingAttributeException(object, field)); } } return super.visit(object); }