return elementExtension;
}
protected void addAttribute(MethodDeclaration d, Class uiComponentClass, List properties, List attributes,
Namespace namespace) {
UIComponentTagAttribute componentAttribute = d.getAnnotation(UIComponentTagAttribute.class);
if (componentAttribute != null) {
String simpleName = d.getSimpleName();
if (simpleName.startsWith("set")) {
String attributeStr = simpleName.substring(3, 4).toLowerCase(Locale.ENGLISH) + simpleName.substring(4);
String methodStr;
if (componentAttribute.type().length == 1
&& (componentAttribute.type()[0].equals(Boolean.class.getName())
|| componentAttribute.type()[0].equals("boolean"))) {
methodStr = "is" + simpleName.substring(3);
} else {
methodStr = "get" + simpleName.substring(3);
}
try {
uiComponentClass.getMethod(methodStr, new Class[0]);
Element property = new Element(PROPERTY, namespace);
Element propertyName = new Element(PROPERTY_NAME, namespace);
Element propertyClass = new Element(PROPERTY_CLASS, namespace);
propertyName.setText(attributeStr);
addClass(componentAttribute, propertyClass);
addDescription(d, property, namespace);
property.addContent(propertyName);
property.addContent(propertyClass);
if (componentAttribute.defaultValue().length() > 0) {
Element defaultValue = new Element(DEFAULT_VALUE, namespace);
defaultValue.setText(componentAttribute.defaultValue());
property.addContent(defaultValue);
}
property.addContent(createPropertyOrAttributeExtension(PROPERTY_EXTENSION, d, componentAttribute, namespace));
properties.add(property);
} catch (NoSuchMethodException e) {
// if property not found should be attribute
Element attribute = new Element(ATTRIBUTE, namespace);
Element attributeName = new Element(ATTRIBUTE_NAME, namespace);
Element attributeClass = new Element(ATTRIBUTE_CLASS, namespace);
attributeName.setText(attributeStr);
addClass(componentAttribute, attributeClass);
addDescription(d, attribute, namespace);
attribute.addContent(attributeName);
attribute.addContent(attributeClass);
if (componentAttribute.defaultValue().length() > 0) {
Element defaultValue = new Element(DEFAULT_VALUE, namespace);
defaultValue.setText(componentAttribute.defaultValue());
attribute.addContent(defaultValue);
}
attribute.addContent(createPropertyOrAttributeExtension(ATTRIBUTE_EXTENSION, d,
componentAttribute, namespace));