View Javadoc

1   /*
2    * ModeShape (http://www.modeshape.org)
3    * See the COPYRIGHT.txt file distributed with this work for information
4    * regarding copyright ownership.  Some portions may be licensed
5    * to Red Hat, Inc. under one or more contributor license agreements.
6    * See the AUTHORS.txt file in the distribution for a full listing of 
7    * individual contributors. 
8    *
9    * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
10   * is licensed to you under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation; either version 2.1 of
12   * the License, or (at your option) any later version.
13   *
14   * ModeShape is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this software; if not, write to the Free
21   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23   */
24  package org.modeshape.sequencer.java.metadata;
25  
26  import java.util.ArrayList;
27  import java.util.List;
28  
29  /**
30   * Exposes meta data of a top level type.
31   */
32  public class TypeMetadata {
33  
34      public static final int PUBLIC_MODIFIER = 0;
35  
36      /** The name. */
37      private String name;
38  
39      private String superClassName;
40  
41      /** All modifiers of a top level type */
42      private List<ModifierMetadata> modifiers = new ArrayList<ModifierMetadata>();
43  
44      /** All annotations of a top level type */
45      private List<AnnotationMetadata> annotations = new ArrayList<AnnotationMetadata>();
46  
47      /** All fields of a top level type */
48      private List<FieldMetadata> fields = new ArrayList<FieldMetadata>();
49  
50      /** All methods of a top level type */
51      private List<MethodMetadata> methods = new ArrayList<MethodMetadata>();
52  
53      /** All superinterfaces of a top level type */
54      private final List<String> interfaceNames = new ArrayList<String>();
55  
56      /**
57       * Get the name.
58       * 
59       * @return the name.
60       */
61      public String getName() {
62          return name;
63      }
64  
65      /**
66       * Set the name.
67       * 
68       * @param name Sets name to the specified value.
69       */
70      public void setName( String name ) {
71          this.name = name;
72      }
73  
74      public String getSuperClassName() {
75          return superClassName;
76      }
77  
78      public void setSuperClassName( String superClassName ) {
79          this.superClassName = superClassName;
80      }
81  
82      public List<String> getInterfaceNames() {
83          return interfaceNames;
84      }
85  
86      /**
87       * @return annotations
88       */
89      public List<AnnotationMetadata> getAnnotations() {
90          return annotations;
91      }
92  
93      /**
94       * @param annotations Sets annotations to the specified value.
95       */
96      public void setAnnotations( List<AnnotationMetadata> annotations ) {
97          this.annotations = annotations;
98      }
99  
100     /**
101      * @return modifiers
102      */
103     public List<ModifierMetadata> getModifiers() {
104         return modifiers;
105     }
106 
107     /**
108      * @param modifiers Sets modifiers to the specified value.
109      */
110     public void setModifiers( List<ModifierMetadata> modifiers ) {
111         this.modifiers = modifiers;
112     }
113 
114     /**
115      * @param modifierName the name of the modifier to check for
116      * @return true if the type has a modifier of that name, otherwise false
117      */
118     public boolean hasModifierNamed( String modifierName ) {
119         for (ModifierMetadata modifier : modifiers) {
120             if (modifierName.equals(modifier.getName())) {
121                 return true;
122             }
123         }
124 
125         return false;
126 
127     }
128 
129     /**
130      * Gets a ordered lists of {@link FieldMetadata} from the unit.
131      * 
132      * @return all fields of this unit if there is one.
133      */
134     public List<FieldMetadata> getFields() {
135         return this.fields;
136     }
137 
138     /**
139      * @param fields Sets fields to the specified value.
140      */
141     public void setFields( List<FieldMetadata> fields ) {
142         this.fields = fields;
143     }
144 
145     /**
146      * Gets all {@link MethodMetadata} from the unit.
147      * 
148      * @return all methods from the units.
149      */
150     public List<MethodMetadata> getMethods() {
151         return methods;
152     }
153 
154     /**
155      * @param methods Sets methods to the specified value.
156      */
157     public void setMethods( List<MethodMetadata> methods ) {
158         this.methods = methods;
159     }
160 
161 }