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