1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.logging.log4j.audit.generator;
18
19 public class VariableDefinition implements Comparable<VariableDefinition> {
20 private String visability;
21 private boolean makeStatic = false;
22 private boolean makeFinal = false;
23 private boolean createGetter = false;
24 private boolean createSetter = false;
25 private String type;
26 private String name;
27 private String initialValue;
28 private String annotation = null;
29
30 public VariableDefinition(String visability, String type, String name,
31 String initialValue) {
32 this.visability = visability;
33 this.type = type;
34 this.name = name;
35 this.initialValue = initialValue;
36 }
37
38 public VariableDefinition(String visability, String type, String name,
39 String initialValue, String annotation) {
40 this.visability = visability;
41 this.type = type;
42 this.name = name;
43 this.initialValue = initialValue;
44 this.annotation = annotation;
45 }
46
47 public String getAnnotation() {
48 return annotation;
49 }
50
51 public String getInitialValue() {
52 return initialValue;
53 }
54
55 public String getName() {
56 return name;
57 }
58
59 public String getType() {
60 return type;
61 }
62
63 public String getVisability() {
64 return visability;
65 }
66
67 public boolean isCreateGetter() {
68 return createGetter;
69 }
70
71 public boolean isCreateSetter() {
72 return createSetter;
73 }
74
75 public boolean isMakeFinal() {
76 return makeFinal;
77 }
78
79 public boolean isMakeStatic() {
80 return makeStatic;
81 }
82
83 public void setAnnotation(String annotation) {
84 this.annotation = annotation;
85 }
86
87 public void setCreateGetter(boolean createGetter) {
88 this.createGetter = createGetter;
89 }
90
91 public void setCreateSetter(boolean createSetter) {
92 this.createSetter = createSetter;
93 }
94
95 public void setInitialValue(String initialValue) {
96 this.initialValue = initialValue;
97 }
98
99 public void setMakeFinal(boolean makeFinal) {
100 this.makeFinal = makeFinal;
101 }
102
103 public void setMakeStatic(boolean makeStatic) {
104 this.makeStatic = makeStatic;
105 }
106
107 public void setName(String name) {
108 this.name = name;
109 }
110
111 public void setType(String type) {
112 this.type = type;
113 }
114
115 public void setVisability(String visability) {
116 this.visability = visability;
117 }
118
119 @Override
120 public String toString() {
121 StringBuilder sb = new StringBuilder();
122 if (getAnnotation() != null) {
123 sb.append(getAnnotation());
124 sb.append("\n");
125 }
126
127 sb.append(visability).append(" ");
128 if (isMakeStatic()) {
129 sb.append("static ");
130 }
131 if (isMakeFinal()) {
132 sb.append("final ");
133 }
134 sb.append(type).append(" ").append(name);
135 if (initialValue != null && initialValue.length() > 0) {
136 sb.append(" = ").append(initialValue);
137 }
138 sb.append(";");
139
140
141
142 return sb.toString();
143 }
144
145 @Override
146 public int compareTo(VariableDefinition arg0) {
147 return getName().compareTo(arg0.getName());
148 }
149 }