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    @Override
73    public int getPropertiesSize() {
74      return index;
75    }
76  
77    @Override
78    public int getPropertiesSizePlusOne() {
79      return index + 1;
80    }
81  
82    public int getNonTransientPropertiesSize() {
83      return nonTransientIndex;
84    }
85  
86    public int getNonTransientPropertiesSizePlusOne() {
87      return nonTransientIndex + 1;
88    }
89  
90    public boolean isMessages() {
91      return messages;
92    }
93  
94    public void setMessages(final boolean messages) {
95      this.messages = messages;
96    }
97  
98    public void setDescription(final String description) {
99      this.description = description;
100   }
101 
102   public String getDescription() {
103     return description;
104   }
105 
106   public void setDeprecated(final boolean deprecated) {
107     this.deprecated = deprecated;
108   }
109 
110   public boolean isDeprecated() {
111     return deprecated;
112   }
113 }