View Javadoc
1   /*
2    *    Copyright 2006-2023 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.mybatis.generator.api.dom.java;
17  
18  import java.util.ArrayList;
19  import java.util.LinkedHashSet;
20  import java.util.List;
21  import java.util.Set;
22  
23  public abstract class AbstractJavaType extends JavaElement {
24  
25      private final FullyQualifiedJavaType type;
26  
27      private final Set<FullyQualifiedJavaType> superInterfaceTypes = new LinkedHashSet<>();
28  
29      private final List<InnerClass> innerClasses = new ArrayList<>();
30  
31      private final List<InnerEnum> innerEnums = new ArrayList<>();
32  
33      private final List<InnerInterface> innerInterfaces = new ArrayList<>();
34  
35      private final List<Field> fields = new ArrayList<>();
36  
37      private final List<Method> methods = new ArrayList<>();
38  
39      protected AbstractJavaType(FullyQualifiedJavaType type) {
40          this.type = type;
41      }
42  
43      protected AbstractJavaType(String type) {
44          this.type = new FullyQualifiedJavaType(type);
45      }
46  
47      public List<InnerClass> getInnerClasses() {
48          return innerClasses;
49      }
50  
51      public void addInnerClass(InnerClass innerClass) {
52          innerClasses.add(innerClass);
53      }
54  
55      public List<InnerEnum> getInnerEnums() {
56          return innerEnums;
57      }
58  
59      public void addInnerEnum(InnerEnum innerEnum) {
60          innerEnums.add(innerEnum);
61      }
62  
63      public List<InnerInterface> getInnerInterfaces() {
64          return innerInterfaces;
65      }
66  
67      public void addInnerInterface(InnerInterface innerInterface) {
68          innerInterfaces.add(innerInterface);
69      }
70  
71      public List<Field> getFields() {
72          return fields;
73      }
74  
75      public void addField(Field field) {
76          fields.add(field);
77      }
78  
79      public List<Method> getMethods() {
80          return methods;
81      }
82  
83      public void addMethod(Method method) {
84          methods.add(method);
85      }
86  
87      public void addSuperInterface(FullyQualifiedJavaType superInterface) {
88          superInterfaceTypes.add(superInterface);
89      }
90  
91      public FullyQualifiedJavaType getType() {
92          return type;
93      }
94  
95      public Set<FullyQualifiedJavaType> getSuperInterfaceTypes() {
96          return superInterfaceTypes;
97      }
98  }