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.List;
20  import java.util.Optional;
21  
22  /**
23   * This class encapsulates the idea of an inner class - it has methods that make it easy to generate inner classes.
24   *
25   * @author Jeff Butler
26   */
27  public class InnerClass extends AbstractJavaType {
28  
29      private final List<TypeParameter> typeParameters = new ArrayList<>();
30  
31      private FullyQualifiedJavaType superClass;
32  
33      private boolean isAbstract;
34  
35      private final List<InitializationBlock> initializationBlocks = new ArrayList<>();
36  
37      private boolean isFinal;
38  
39      public InnerClass(FullyQualifiedJavaType type) {
40          super(type);
41      }
42  
43      public InnerClass(String type) {
44          super(type);
45      }
46  
47      public Optional<FullyQualifiedJavaType> getSuperClass() {
48          return Optional.ofNullable(superClass);
49      }
50  
51      public void setSuperClass(FullyQualifiedJavaType superClass) {
52          this.superClass = superClass;
53      }
54  
55      public void setSuperClass(String superClassType) {
56          this.superClass = new FullyQualifiedJavaType(superClassType);
57      }
58  
59      public List<TypeParameter> getTypeParameters() {
60          return this.typeParameters;
61      }
62  
63      public void addTypeParameter(TypeParameter typeParameter) {
64          this.typeParameters.add(typeParameter);
65      }
66  
67      public List<InitializationBlock> getInitializationBlocks() {
68          return initializationBlocks;
69      }
70  
71      public void addInitializationBlock(InitializationBlock initializationBlock) {
72          initializationBlocks.add(initializationBlock);
73      }
74  
75      public boolean isAbstract() {
76          return isAbstract;
77      }
78  
79      public void setAbstract(boolean isAbtract) {
80          this.isAbstract = isAbtract;
81      }
82  
83      public boolean isFinal() {
84          return isFinal;
85      }
86  
87      public void setFinal(boolean isFinal) {
88          this.isFinal = isFinal;
89      }
90  }