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.Optional;
19  
20  public class Field extends JavaElement {
21      private FullyQualifiedJavaType type;
22      private String name;
23      private String initializationString;
24      private boolean isTransient;
25      private boolean isVolatile;
26      private boolean isFinal;
27  
28      public Field(String name, FullyQualifiedJavaType type) {
29          this.name = name;
30          this.type = type;
31      }
32  
33      public Field(Field field) {
34          super(field);
35          this.type = field.type;
36          this.name = field.name;
37          this.initializationString = field.initializationString;
38          this.isTransient = field.isTransient;
39          this.isVolatile = field.isVolatile;
40          this.isFinal = field.isFinal;
41      }
42  
43      public String getName() {
44          return name;
45      }
46  
47      public void setName(String name) {
48          this.name = name;
49      }
50  
51      public FullyQualifiedJavaType getType() {
52          return type;
53      }
54  
55      public void setType(FullyQualifiedJavaType type) {
56          this.type = type;
57      }
58  
59      public Optional<String> getInitializationString() {
60          return Optional.ofNullable(initializationString);
61      }
62  
63      public void setInitializationString(String initializationString) {
64          this.initializationString = initializationString;
65      }
66  
67      public boolean isTransient() {
68          return isTransient;
69      }
70  
71      public void setTransient(boolean isTransient) {
72          this.isTransient = isTransient;
73      }
74  
75      public boolean isVolatile() {
76          return isVolatile;
77      }
78  
79      public void setVolatile(boolean isVolatile) {
80          this.isVolatile = isVolatile;
81      }
82  
83      public boolean isFinal() {
84          return isFinal;
85      }
86  
87      public void setFinal(boolean isFinal) {
88          this.isFinal = isFinal;
89      }
90  }