use of com.blackducksoftware.integration.hub.docker.dockerinspector.help.ValueDescription in project hub-docker-inspector by blackducksoftware.
the class Config method init.
@PostConstruct
public void init() throws IllegalArgumentException, IllegalAccessException {
final Object configObject = this;
publicOptions = new ArrayList<>();
allKeys = new ArrayList<>();
optionsByKey = new HashMap<>();
optionsByFieldName = new HashMap<>();
for (final Field field : configObject.getClass().getDeclaredFields()) {
final Annotation[] declaredAnnotations = field.getDeclaredAnnotations();
if (declaredAnnotations.length > 0) {
for (final Annotation annotation : declaredAnnotations) {
if (annotation.annotationType().getName().equals(ValueDescription.class.getName())) {
logger.debug(String.format("ValueDescription annotated config object field: %s", field.getName()));
final String propMappingString = field.getAnnotation(Value.class).value();
final String propName = SpringValueUtils.springKeyFromValueAnnotation(propMappingString);
final Object fieldValueObject = field.get(configObject);
if (fieldValueObject == null) {
logger.warn(String.format("propName %s field is null", propName));
continue;
}
final String value = fieldValueObject.toString();
logger.trace(String.format("adding prop key %s [value: %s]", propName, value));
allKeys.add(propName);
final ValueDescription valueDescription = field.getAnnotation(ValueDescription.class);
final DockerInspectorOption opt = new DockerInspectorOption(propName, field.getName(), value, valueDescription.description(), field.getType(), valueDescription.defaultValue(), valueDescription.group(), valueDescription.deprecated());
optionsByKey.put(propName, opt);
logger.trace(String.format("adding field name %s to optionsByFieldName", field.getName()));
optionsByFieldName.put(field.getName(), opt);
if (!Config.GROUP_PRIVATE.equals(valueDescription.group())) {
publicOptions.add(opt);
} else {
logger.debug(String.format("private prop: propName: %s, fieldName: %s, group: %s, description: %s", propName, field.getName(), valueDescription.group(), valueDescription.description()));
}
}
}
}
}
}
Aggregations