001 package edu.rice.cs.javalanglevels.tree;
002
003 import edu.rice.cs.javalanglevels.SourceInfo;
004
005 /**
006 * Class ConcreteMethodDef, a component of the JExpressionIF composite hierarchy.
007 * Note: null is not allowed as a value for any field.
008 * @version Generated automatically by ASTGen at Sun Mar 04 23:01:27 CST 2012
009 */
010 public class ConcreteMethodDef extends MethodDef {
011 private final BracedBody _body;
012
013 /**
014 * Constructs a ConcreteMethodDef.
015 * @throws java.lang.IllegalArgumentException If any parameter to the constructor is null.
016 */
017 public ConcreteMethodDef(SourceInfo in_sourceInfo, ModifiersAndVisibility in_mav, TypeParameter[] in_typeParams, ReturnTypeI in_result, Word in_name, FormalParameter[] in_params, ReferenceType[] in_throws, BracedBody in_body) {
018 super(in_sourceInfo, in_mav, in_typeParams, in_result, in_name, in_params, in_throws);
019
020 if (in_body == null) {
021 throw new java.lang.IllegalArgumentException("Parameter 'body' to the ConcreteMethodDef constructor was null. This class may not have null field values.");
022 }
023 _body = in_body;
024 }
025
026 final public BracedBody getBody() { return _body; }
027
028 public <RetType> RetType visit(JExpressionIFVisitor<RetType> visitor) { return visitor.forConcreteMethodDef(this); }
029 public void visit(JExpressionIFVisitor_void visitor) { visitor.forConcreteMethodDef(this); }
030
031 /**
032 * Implementation of toString that uses
033 * {@link #output} to generated nicely tabbed tree.
034 */
035 public java.lang.String toString() {
036 java.io.StringWriter w = new java.io.StringWriter();
037 output(w);
038 return w.toString();
039 }
040
041 /**
042 * Prints this object out as a nicely tabbed tree.
043 */
044 public void output(java.io.Writer writer) {
045 outputHelp(new TabPrintWriter(writer, 2));
046 }
047
048 public void outputHelp(TabPrintWriter writer) {
049 writer.print("ConcreteMethodDef" + ":");
050 writer.indent();
051
052 writer.startLine("");
053 writer.print("sourceInfo = ");
054 SourceInfo temp_sourceInfo = getSourceInfo();
055 if (temp_sourceInfo == null) {
056 writer.print("null");
057 } else {
058 writer.print(temp_sourceInfo);
059 }
060
061 writer.startLine("");
062 writer.print("mav = ");
063 ModifiersAndVisibility temp_mav = getMav();
064 if (temp_mav == null) {
065 writer.print("null");
066 } else {
067 temp_mav.outputHelp(writer);
068 }
069
070 writer.startLine("");
071 writer.print("typeParams = ");
072 writer.print("{");
073 writer.indent();
074 for (int i = 0; i < getTypeParams().length; i++) {
075 TypeParameter temp_typeParams = getTypeParams()[i];
076 writer.startLine("#" + i + ": ");
077 if (temp_typeParams == null) {
078 writer.print("null");
079 } else {
080 temp_typeParams.outputHelp(writer);
081 }
082 }
083 writer.unindent();
084 if (getTypeParams().length > 0) {
085 writer.startLine("");
086 }
087 writer.print("}");
088
089 writer.startLine("");
090 writer.print("result = ");
091 ReturnTypeI temp_result = getResult();
092 if (temp_result == null) {
093 writer.print("null");
094 } else {
095 temp_result.outputHelp(writer);
096 }
097
098 writer.startLine("");
099 writer.print("name = ");
100 Word temp_name = getName();
101 if (temp_name == null) {
102 writer.print("null");
103 } else {
104 temp_name.outputHelp(writer);
105 }
106
107 writer.startLine("");
108 writer.print("params = ");
109 writer.print("{");
110 writer.indent();
111 for (int i = 0; i < getParams().length; i++) {
112 FormalParameter temp_params = getParams()[i];
113 writer.startLine("#" + i + ": ");
114 if (temp_params == null) {
115 writer.print("null");
116 } else {
117 temp_params.outputHelp(writer);
118 }
119 }
120 writer.unindent();
121 if (getParams().length > 0) {
122 writer.startLine("");
123 }
124 writer.print("}");
125
126 writer.startLine("");
127 writer.print("throws = ");
128 writer.print("{");
129 writer.indent();
130 for (int i = 0; i < getThrows().length; i++) {
131 ReferenceType temp_throws = getThrows()[i];
132 writer.startLine("#" + i + ": ");
133 if (temp_throws == null) {
134 writer.print("null");
135 } else {
136 temp_throws.outputHelp(writer);
137 }
138 }
139 writer.unindent();
140 if (getThrows().length > 0) {
141 writer.startLine("");
142 }
143 writer.print("}");
144
145 writer.startLine("");
146 writer.print("body = ");
147 BracedBody temp_body = getBody();
148 if (temp_body == null) {
149 writer.print("null");
150 } else {
151 temp_body.outputHelp(writer);
152 }
153 writer.unindent();
154 }
155
156 /**
157 * Implementation of equals that is based on the values
158 * of the fields of the object. Thus, two objects
159 * created with identical parameters will be equal.
160 */
161 public boolean equals(java.lang.Object obj) {
162 if (obj == null) return false;
163 if ((obj.getClass() != this.getClass()) || (obj.hashCode() != this.hashCode())) {
164 return false;
165 } else {
166 ConcreteMethodDef casted = (ConcreteMethodDef) obj;
167 if (! (getMav().equals(casted.getMav()))) return false;
168 if (this.getTypeParams().length != casted.getTypeParams().length) return false;
169 for (int i = 0; i < getTypeParams().length; i++) if (! getTypeParams()[i].equals(casted.getTypeParams()[i])) return false;
170 if (! (getResult().equals(casted.getResult()))) return false;
171 if (! (getName().equals(casted.getName()))) return false;
172 if (this.getParams().length != casted.getParams().length) return false;
173 for (int i = 0; i < getParams().length; i++) if (! getParams()[i].equals(casted.getParams()[i])) return false;
174 if (this.getThrows().length != casted.getThrows().length) return false;
175 for (int i = 0; i < getThrows().length; i++) if (! getThrows()[i].equals(casted.getThrows()[i])) return false;
176 if (! (getBody().equals(casted.getBody()))) return false;
177 return true;
178 }
179 }
180
181 /**
182 * Implementation of hashCode that is consistent with
183 * equals. The value of the hashCode is formed by
184 * XORing the hashcode of the class object with
185 * the hashcodes of all the fields of the object.
186 */
187 protected int generateHashCode() {
188 int code = getClass().hashCode();
189 code ^= 0;
190 code ^= getMav().hashCode();
191 for (int i = 0; i < getTypeParams().length; i++) code ^= getTypeParams()[i].hashCode();
192 code ^= getResult().hashCode();
193 code ^= getName().hashCode();
194 for (int i = 0; i < getParams().length; i++) code ^= getParams()[i].hashCode();
195 for (int i = 0; i < getThrows().length; i++) code ^= getThrows()[i].hashCode();
196 code ^= getBody().hashCode();
197 return code;
198 }
199 }