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