use of org.glassfish.admin.rest.composite.metadata.AttributeReference in project Payara by payara.
the class CompositeUtil method analyzeInterface.
private void analyzeInterface(Class<?> iface, Map<String, Map<String, Object>> properties) throws SecurityException {
// find class level bean reference
String defaultBean = null;
if (iface.isAnnotationPresent(DefaultBeanReference.class)) {
DefaultBeanReference beanRef = iface.getAnnotation(DefaultBeanReference.class);
defaultBean = beanRef.bean();
}
for (Method method : iface.getMethods()) {
String name = method.getName();
final boolean isGetter = name.startsWith("get");
if (isGetter || name.startsWith("set")) {
name = name.substring(3);
Map<String, Object> property = properties.get(name);
if (property == null) {
property = new HashMap<String, Object>();
properties.put(name, property);
}
String bean = null;
String attribute = null;
AttributeReference ar = method.getAnnotation(AttributeReference.class);
if (ar != null) {
bean = ar.bean();
attribute = ar.attribute();
}
if (!StringUtil.notEmpty(bean)) {
bean = defaultBean;
}
if (!StringUtil.notEmpty(attribute)) {
attribute = name;
}
if (StringUtil.notEmpty(bean) && StringUtil.notEmpty(attribute)) {
property.put("annotations", gatherReferencedAttributes(bean, attribute));
}
Attribute attr = method.getAnnotation(Attribute.class);
if (attr != null) {
property.put("defaultValue", attr.defaultValue());
}
Class<?> type = isGetter ? method.getReturnType() : method.getParameterTypes()[0];
property.put("type", type);
}
}
}
Aggregations