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  
21  public abstract class JavaElement {
22  
23      private final List<String> javaDocLines = new ArrayList<>();
24  
25      private JavaVisibility visibility = JavaVisibility.DEFAULT;
26  
27      private boolean isStatic;
28  
29      private final List<String> annotations = new ArrayList<>();
30  
31      protected JavaElement() {
32          super();
33      }
34  
35      protected JavaElement(JavaElement original) {
36          this.annotations.addAll(original.annotations);
37          this.isStatic = original.isStatic;
38          this.javaDocLines.addAll(original.javaDocLines);
39          this.visibility = original.visibility;
40      }
41  
42      public List<String> getJavaDocLines() {
43          return javaDocLines;
44      }
45  
46      public void addJavaDocLine(String javaDocLine) {
47          javaDocLines.add(javaDocLine);
48      }
49  
50      public List<String> getAnnotations() {
51          return annotations;
52      }
53  
54      public void addAnnotation(String annotation) {
55          annotations.add(annotation);
56      }
57  
58      public JavaVisibility getVisibility() {
59          return visibility;
60      }
61  
62      public void setVisibility(JavaVisibility visibility) {
63          this.visibility = visibility;
64      }
65  
66      public void addSuppressTypeWarningsAnnotation() {
67          addAnnotation("@SuppressWarnings(\"unchecked\")"); //$NON-NLS-1$
68      }
69  
70      public boolean isStatic() {
71          return isStatic;
72      }
73  
74      public void setStatic(boolean isStatic) {
75          this.isStatic = isStatic;
76      }
77  }