1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.apt.generate;
21
22 import org.apache.myfaces.tobago.apt.AnnotationUtils;
23 import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
24
25 import javax.lang.model.element.TypeElement;
26 import java.util.ArrayList;
27 import java.util.List;
28
29 public class ComponentInfo extends TagInfo {
30 private List<PropertyInfo> nonTransientProperties = new ArrayList<>();
31 private List<PropertyInfo> transientProperties = new ArrayList<>();
32 private boolean messages;
33 private String description;
34 private boolean deprecated;
35 private int index = 0;
36 private int nonTransientIndex = 0;
37 private List<String> behaviors = new ArrayList<>();
38 private String defaultBehavior;
39
40 public ComponentInfo(final TypeElement declaration, final UIComponentTag componentTag) {
41 super(declaration.getQualifiedName().toString(), componentTag.uiComponent(), componentTag.rendererType());
42
43 setComponentType(AnnotationUtils.componentType(componentTag));
44 setComponentFamily(componentTag.componentFamily());
45 setComponentClassName(componentTag.uiComponent());
46 }
47
48
49
50
51 @Deprecated
52 public ComponentInfo(final String sourceClass, final String qualifiedName, final String rendererType) {
53 super(sourceClass, qualifiedName, new String[]{rendererType});
54 }
55
56 public void addPropertyInfo(final ComponentPropertyInfo propertyInfo) {
57 getProperties().add(propertyInfo);
58 propertyInfo.setIndex(index);
59 index++;
60 if (!propertyInfo.isTransient()) {
61 nonTransientProperties.add(propertyInfo);
62 propertyInfo.setNonTransientIndex(nonTransientIndex);
63 nonTransientIndex++;
64 } else {
65 transientProperties.add(propertyInfo);
66 }
67 }
68
69 public List<PropertyInfo> getNonTransientProperties() {
70 return nonTransientProperties;
71 }
72
73 public List<PropertyInfo> getTransientProperties() {
74 return transientProperties;
75 }
76
77 @Override
78 public int getPropertiesSize() {
79 return index;
80 }
81
82 @Override
83 public int getPropertiesSizePlusOne() {
84 return index + 1;
85 }
86
87 public int getNonTransientPropertiesSize() {
88 return nonTransientIndex;
89 }
90
91 public int getNonTransientPropertiesSizePlusOne() {
92 return nonTransientIndex + 1;
93 }
94
95 public boolean isMessages() {
96 return messages;
97 }
98
99 public void setMessages(final boolean messages) {
100 this.messages = messages;
101 }
102
103 public void setDescription(final String description) {
104 this.description = description;
105 }
106
107 public String getDescription() {
108 return description;
109 }
110
111 public void setDeprecated(final boolean deprecated) {
112 this.deprecated = deprecated;
113 }
114
115 public boolean isDeprecated() {
116 return deprecated;
117 }
118
119 public List<String> getBehaviors() {
120 return behaviors;
121 }
122
123 public String getDefaultBehavior() {
124 return defaultBehavior;
125 }
126
127 public void setDefaultBehavior(final String defaultBehavior) {
128 this.defaultBehavior = defaultBehavior;
129 }
130 }