|
1 |
| package edu.rice.cs.javalanglevels.tree; |
|
2 |
| |
|
3 |
| import edu.rice.cs.javalanglevels.SourceInfo; |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| public class ConstructorDef extends JExpression implements BodyItemI { |
|
11 |
| private final Word _name; |
|
12 |
| private final ModifiersAndVisibility _mav; |
|
13 |
| private final FormalParameter[] _parameters; |
|
14 |
| private final ReferenceType[] _throws; |
|
15 |
| private final BracedBody _statements; |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
40
| public ConstructorDef(SourceInfo in_sourceInfo, Word in_name, ModifiersAndVisibility in_mav, FormalParameter[] in_parameters, ReferenceType[] in_throws, BracedBody in_statements) {
|
|
22 |
40
| super(in_sourceInfo);
|
|
23 |
| |
|
24 |
40
| if (in_name == null) {
|
|
25 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'name' to the ConstructorDef constructor was null. This class may not have null field values.");
|
|
26 |
| } |
|
27 |
40
| _name = in_name;
|
|
28 |
| |
|
29 |
40
| if (in_mav == null) {
|
|
30 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'mav' to the ConstructorDef constructor was null. This class may not have null field values.");
|
|
31 |
| } |
|
32 |
40
| _mav = in_mav;
|
|
33 |
| |
|
34 |
40
| if (in_parameters == null) {
|
|
35 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'parameters' to the ConstructorDef constructor was null. This class may not have null field values.");
|
|
36 |
| } |
|
37 |
40
| _parameters = in_parameters;
|
|
38 |
| |
|
39 |
40
| if (in_throws == null) {
|
|
40 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'throws' to the ConstructorDef constructor was null. This class may not have null field values.");
|
|
41 |
| } |
|
42 |
40
| _throws = in_throws;
|
|
43 |
| |
|
44 |
40
| if (in_statements == null) {
|
|
45 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'statements' to the ConstructorDef constructor was null. This class may not have null field values.");
|
|
46 |
| } |
|
47 |
40
| _statements = in_statements;
|
|
48 |
| } |
|
49 |
| |
|
50 |
54
| final public Word getName() { return _name; }
|
|
51 |
105
| final public ModifiersAndVisibility getMav() { return _mav; }
|
|
52 |
131
| final public FormalParameter[] getParameters() { return _parameters; }
|
|
53 |
93
| final public ReferenceType[] getThrows() { return _throws; }
|
|
54 |
62
| final public BracedBody getStatements() { return _statements; }
|
|
55 |
| |
|
56 |
64
| public <RetType> RetType visit(JExpressionIFVisitor<RetType> visitor) { return visitor.forConstructorDef(this); }
|
|
57 |
0
| public void visit(JExpressionIFVisitor_void visitor) { visitor.forConstructorDef(this); }
|
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
0
| public java.lang.String toString() {
|
|
64 |
0
| java.io.StringWriter w = new java.io.StringWriter();
|
|
65 |
0
| output(w);
|
|
66 |
0
| return w.toString();
|
|
67 |
| } |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
0
| public void output(java.io.Writer writer) {
|
|
73 |
0
| outputHelp(new TabPrintWriter(writer, 2));
|
|
74 |
| } |
|
75 |
| |
|
76 |
12
| public void outputHelp(TabPrintWriter writer) {
|
|
77 |
12
| writer.print("ConstructorDef" + ":");
|
|
78 |
12
| writer.indent();
|
|
79 |
| |
|
80 |
12
| writer.startLine("");
|
|
81 |
12
| writer.print("sourceInfo = ");
|
|
82 |
12
| SourceInfo temp_sourceInfo = getSourceInfo();
|
|
83 |
12
| if (temp_sourceInfo == null) {
|
|
84 |
0
| writer.print("null");
|
|
85 |
| } else { |
|
86 |
12
| writer.print(temp_sourceInfo);
|
|
87 |
| } |
|
88 |
| |
|
89 |
12
| writer.startLine("");
|
|
90 |
12
| writer.print("name = ");
|
|
91 |
12
| Word temp_name = getName();
|
|
92 |
12
| if (temp_name == null) {
|
|
93 |
0
| writer.print("null");
|
|
94 |
| } else { |
|
95 |
12
| temp_name.outputHelp(writer);
|
|
96 |
| } |
|
97 |
| |
|
98 |
12
| writer.startLine("");
|
|
99 |
12
| writer.print("mav = ");
|
|
100 |
12
| ModifiersAndVisibility temp_mav = getMav();
|
|
101 |
12
| if (temp_mav == null) {
|
|
102 |
0
| writer.print("null");
|
|
103 |
| } else { |
|
104 |
12
| temp_mav.outputHelp(writer);
|
|
105 |
| } |
|
106 |
| |
|
107 |
12
| writer.startLine("");
|
|
108 |
12
| writer.print("parameters = ");
|
|
109 |
12
| writer.print("{");
|
|
110 |
12
| writer.indent();
|
|
111 |
12
| for (int i = 0; i < getParameters().length; i++) {
|
|
112 |
12
| FormalParameter temp_parameters = getParameters()[i];
|
|
113 |
12
| writer.startLine("#" + i + ": ");
|
|
114 |
12
| if (temp_parameters == null) {
|
|
115 |
0
| writer.print("null");
|
|
116 |
| } else { |
|
117 |
12
| temp_parameters.outputHelp(writer);
|
|
118 |
| } |
|
119 |
| } |
|
120 |
12
| writer.unindent();
|
|
121 |
12
| if (getParameters().length > 0) {
|
|
122 |
6
| writer.startLine("");
|
|
123 |
| } |
|
124 |
12
| writer.print("}");
|
|
125 |
| |
|
126 |
12
| writer.startLine("");
|
|
127 |
12
| writer.print("throws = ");
|
|
128 |
12
| writer.print("{");
|
|
129 |
12
| writer.indent();
|
|
130 |
12
| for (int i = 0; i < getThrows().length; i++) {
|
|
131 |
0
| ReferenceType temp_throws = getThrows()[i];
|
|
132 |
0
| writer.startLine("#" + i + ": ");
|
|
133 |
0
| if (temp_throws == null) {
|
|
134 |
0
| writer.print("null");
|
|
135 |
| } else { |
|
136 |
0
| temp_throws.outputHelp(writer);
|
|
137 |
| } |
|
138 |
| } |
|
139 |
12
| writer.unindent();
|
|
140 |
12
| if (getThrows().length > 0) {
|
|
141 |
0
| writer.startLine("");
|
|
142 |
| } |
|
143 |
12
| writer.print("}");
|
|
144 |
| |
|
145 |
12
| writer.startLine("");
|
|
146 |
12
| writer.print("statements = ");
|
|
147 |
12
| BracedBody temp_statements = getStatements();
|
|
148 |
12
| if (temp_statements == null) {
|
|
149 |
0
| writer.print("null");
|
|
150 |
| } else { |
|
151 |
12
| temp_statements.outputHelp(writer);
|
|
152 |
| } |
|
153 |
12
| writer.unindent();
|
|
154 |
| } |
|
155 |
| |
|
156 |
| |
|
157 |
| |
|
158 |
| |
|
159 |
| |
|
160 |
| |
|
161 |
0
| public boolean equals(java.lang.Object obj) {
|
|
162 |
0
| if (obj == null) return false;
|
|
163 |
0
| if ((obj.getClass() != this.getClass()) || (obj.hashCode() != this.hashCode())) {
|
|
164 |
0
| return false;
|
|
165 |
| } else { |
|
166 |
0
| ConstructorDef casted = (ConstructorDef) obj;
|
|
167 |
0
| if (! (getName().equals(casted.getName()))) return false;
|
|
168 |
0
| if (! (getMav().equals(casted.getMav()))) return false;
|
|
169 |
0
| if (this.getParameters().length != casted.getParameters().length) return false;
|
|
170 |
0
| for (int i = 0; i < getParameters().length; i++) if (! getParameters()[i].equals(casted.getParameters()[i])) return false;
|
|
171 |
0
| if (this.getThrows().length != casted.getThrows().length) return false;
|
|
172 |
0
| for (int i = 0; i < getThrows().length; i++) if (! getThrows()[i].equals(casted.getThrows()[i])) return false;
|
|
173 |
0
| if (! (getStatements().equals(casted.getStatements()))) return false;
|
|
174 |
0
| return true;
|
|
175 |
| } |
|
176 |
| } |
|
177 |
| |
|
178 |
| |
|
179 |
| |
|
180 |
| |
|
181 |
| |
|
182 |
| |
|
183 |
| |
|
184 |
0
| protected int generateHashCode() {
|
|
185 |
0
| int code = getClass().hashCode();
|
|
186 |
0
| code ^= 0;
|
|
187 |
0
| code ^= getName().hashCode();
|
|
188 |
0
| code ^= getMav().hashCode();
|
|
189 |
0
| for (int i = 0; i < getParameters().length; i++) code ^= getParameters()[i].hashCode();
|
|
190 |
0
| for (int i = 0; i < getThrows().length; i++) code ^= getThrows()[i].hashCode();
|
|
191 |
0
| code ^= getStatements().hashCode();
|
|
192 |
0
| return code;
|
|
193 |
| } |
|
194 |
| } |