Map<PropertyName, Method> results = new TreeMap<PropertyName, Method>();
for (Method method : modelClass.getMethods()) {
if (VALUE_DRIVERS.containsKey(method.getReturnType()) == false) {
continue;
}
PropertyName property = getPropertyNameIfAccessor(method);
if (property == null) {
continue;
}
results.put(property, method);
}
PropertyOrder annotation = modelClass.getAnnotation(PropertyOrder.class);
if (annotation == null) {
LOG.info("Annotation {} is not defined in {}",
PropertyOrder.class.getSimpleName(),
modelClass.getName());
return results;
}
Map<PropertyName, Method> ordered = new LinkedHashMap<PropertyName, Method>();
for (String name : annotation.value()) {
String[] words = name.split("(_|-)+");
PropertyName propertyName = PropertyName.newInstance(words);
Method method = results.remove(propertyName);
if (method == null) {
LOG.warn("Property {} is not found in {}", name, modelClass.getName());
} else {
ordered.put(propertyName, method);