1 package org.apache.torque.generator.variable;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.torque.generator.qname.QualifiedName;
23
24
25
26
27
28
29
30
31
32 public class Variable
33 {
34
35
36
37 public enum Scope
38 {
39
40
41
42 OUTLET,
43
44
45
46
47
48 CHILDREN,
49
50
51
52
53 FILE,
54
55
56
57 GLOBAL
58 }
59
60
61
62
63 private QualifiedName name;
64
65
66
67
68 private Object value;
69
70
71
72
73 private Scope scope;
74
75
76
77
78
79
80
81
82 public Variable(
83 QualifiedName name,
84 Object value,
85 Scope scope)
86 {
87 if (name == null)
88 {
89 throw new NullPointerException("name must not be null");
90 }
91 if (scope == null)
92 {
93 throw new NullPointerException("scope must not be null");
94 }
95 this.name = name;
96 this.value = value;
97 this.scope = scope;
98 }
99
100
101
102
103
104
105 public QualifiedName getName()
106 {
107 return name;
108 }
109
110
111
112
113
114 public Object getValue()
115 {
116 return value;
117 }
118
119
120
121
122
123
124 public void setValue(Object value)
125 {
126 this.value = value;
127 }
128
129
130
131
132
133
134 public Scope getScope()
135 {
136 return scope;
137 }
138
139 @Override
140 public int hashCode()
141 {
142 final int prime = 31;
143 int result = 1;
144 result = prime * result + ((name == null) ? 0 : name.hashCode());
145 result = prime * result + ((scope == null) ? 0 : scope.hashCode());
146 result = prime * result + ((value == null) ? 0 : value.hashCode());
147 return result;
148 }
149
150 @Override
151 public boolean equals(Object obj)
152 {
153 if (this == obj)
154 {
155 return true;
156 }
157 if (obj == null)
158 {
159 return false;
160 }
161 if (getClass() != obj.getClass())
162 {
163 return false;
164 }
165
166 final Variable other = (Variable) obj;
167
168 if (name == null)
169 {
170 if (other.name != null)
171 {
172 return false;
173 }
174 }
175 else if (!name.equals(other.name))
176 {
177 return false;
178 }
179
180 if (scope == null)
181 {
182 if (other.scope != null)
183 {
184 return false;
185 }
186 }
187 else if (!scope.equals(other.scope))
188 {
189 return false;
190 }
191
192 if (value == null)
193 {
194 if (other.value != null)
195 {
196 return false;
197 }
198 }
199 else if (!value.equals(other.value))
200 {
201 return false;
202 }
203
204 return true;
205 }
206
207 @Override
208 public String toString()
209 {
210 StringBuilder result = new StringBuilder();
211 result.append("(name=").append(name)
212 .append(", value=").append(value)
213 .append(", scope=").append(scope)
214 .append(")");
215 return result.toString();
216 }
217 }