public void applyAutoOverrides(Object aObject) { for (Field field : ReflectionUtil.getFields(aObject)) { if (ConfigurationParameterFactory.isConfigurationParameterField(field)) { String parameterName = ConfigurationParameterFactory .getConfigurationParameterName(field); // Check if there is an auto-override for this parameter String property = autoOverrides.get(parameterName); if (property != null) { try { Object value = FieldUtils.readField(field, aObject, true); setOverride(property, value != null ? value.toString() : null); } catch (IllegalAccessException e) { throw new IllegalStateException(e); } } } } }
/** * A factory method for creating a ConfigurationParameter from a given field definition * * @param field * the field to analyze * @return the configuration parameter. */ public static ConfigurationParameter createPrimitiveParameter(Field field) { if (isConfigurationParameterField(field)) { org.apache.uima.fit.descriptor.ConfigurationParameter annotation = ReflectionUtil .getAnnotation(field, org.apache.uima.fit.descriptor.ConfigurationParameter.class); String name = getConfigurationParameterName(field); boolean multiValued = isMultiValued(field); String parameterType = getConfigurationParameterType(field); return createPrimitiveParameter(name, parameterType, annotation.description(), multiValued, annotation.mandatory()); } else { throw new IllegalArgumentException("field is not annotated with annotation of type " + org.apache.uima.fit.descriptor.ConfigurationParameter.class.getName()); } }
String parameterName = ConfigurationParameterFactory.getConfigurationParameterName(field);