View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
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<PropertyInfo>();
31    private List<PropertyInfo> transientProperties = new ArrayList<PropertyInfo>();
32    private boolean messages;
33    private String description;
34    private boolean deprecated;
35    private int index = 0;
36    private int nonTransientIndex = 0;
37  
38    public ComponentInfo(final TypeElement declaration, final UIComponentTag componentTag) {
39      super(declaration.getQualifiedName().toString(), componentTag.uiComponent(), componentTag.rendererType());
40  
41      setComponentType(AnnotationUtils.componentType(componentTag));
42      setComponentFamily(componentTag.componentFamily());
43      setComponentClassName(componentTag.uiComponent());
44    }
45  
46    @Deprecated
47    public ComponentInfo(final String sourceClass, final String qualifiedName, final String rendererType) {
48      super(sourceClass, qualifiedName, rendererType);
49    }
50  
51    public void addPropertyInfo(final ComponentPropertyInfo propertyInfo) {
52      getProperties().add(propertyInfo);
53      propertyInfo.setIndex(index);
54      index++;
55      if (!propertyInfo.isTransient()) {
56        nonTransientProperties.add(propertyInfo);
57        propertyInfo.setNonTransientIndex(nonTransientIndex);
58        nonTransientIndex++;
59      } else {
60        transientProperties.add(propertyInfo);
61      }
62    }
63  
64    public List<PropertyInfo> getNonTransientProperties() {
65      return nonTransientProperties;
66    }
67  
68    public List<PropertyInfo> getTransientProperties() {
69      return transientProperties;
70    }
71  
72    public int getPropertiesSize() {
73      return index;
74    }
75  
76    public int getPropertiesSizePlusOne() {
77      return index + 1;
78    }
79  
80    public int getNonTransientPropertiesSize() {
81      return nonTransientIndex;
82    }
83  
84    public int getNonTransientPropertiesSizePlusOne() {
85      return nonTransientIndex + 1;
86    }
87  
88    public boolean isMessages() {
89      return messages;
90    }
91  
92    public void setMessages(final boolean messages) {
93      this.messages = messages;
94    }
95  
96    public void setDescription(final String description) {
97      this.description = description;
98    }
99  
100   public String getDescription() {
101     return description;
102   }
103 
104   public void setDeprecated(final boolean deprecated) {
105     this.deprecated = deprecated;
106   }
107 
108   public boolean isDeprecated() {
109     return deprecated;
110   }
111 }