001 package edu.rice.cs.javalanglevels.tree;
002
003 import edu.rice.cs.javalanglevels.SourceInfo;
004
005 /**
006 * Class InnerClassDef, 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 InnerClassDef extends ClassDef implements BodyItemI {
011
012 /**
013 * Constructs a InnerClassDef.
014 * @throws java.lang.IllegalArgumentException If any parameter to the constructor is null.
015 */
016 public InnerClassDef(SourceInfo in_sourceInfo, ModifiersAndVisibility in_mav, Word in_name, TypeParameter[] in_typeParameters, ReferenceType in_superclass, ReferenceType[] in_interfaces, BracedBody in_body) {
017 super(in_sourceInfo, in_mav, in_name, in_typeParameters, in_superclass, in_interfaces, in_body);
018 }
019
020
021 public <RetType> RetType visit(JExpressionIFVisitor<RetType> visitor) { return visitor.forInnerClassDef(this); }
022 public void visit(JExpressionIFVisitor_void visitor) { visitor.forInnerClassDef(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("InnerClassDef" + ":");
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("name = ");
065 Word temp_name = getName();
066 if (temp_name == null) {
067 writer.print("null");
068 } else {
069 temp_name.outputHelp(writer);
070 }
071
072 writer.startLine("");
073 writer.print("typeParameters = ");
074 writer.print("{");
075 writer.indent();
076 for (int i = 0; i < getTypeParameters().length; i++) {
077 TypeParameter temp_typeParameters = getTypeParameters()[i];
078 writer.startLine("#" + i + ": ");
079 if (temp_typeParameters == null) {
080 writer.print("null");
081 } else {
082 temp_typeParameters.outputHelp(writer);
083 }
084 }
085 writer.unindent();
086 if (getTypeParameters().length > 0) {
087 writer.startLine("");
088 }
089 writer.print("}");
090
091 writer.startLine("");
092 writer.print("superclass = ");
093 ReferenceType temp_superclass = getSuperclass();
094 if (temp_superclass == null) {
095 writer.print("null");
096 } else {
097 temp_superclass.outputHelp(writer);
098 }
099
100 writer.startLine("");
101 writer.print("interfaces = ");
102 writer.print("{");
103 writer.indent();
104 for (int i = 0; i < getInterfaces().length; i++) {
105 ReferenceType temp_interfaces = getInterfaces()[i];
106 writer.startLine("#" + i + ": ");
107 if (temp_interfaces == null) {
108 writer.print("null");
109 } else {
110 temp_interfaces.outputHelp(writer);
111 }
112 }
113 writer.unindent();
114 if (getInterfaces().length > 0) {
115 writer.startLine("");
116 }
117 writer.print("}");
118
119 writer.startLine("");
120 writer.print("body = ");
121 BracedBody temp_body = getBody();
122 if (temp_body == null) {
123 writer.print("null");
124 } else {
125 temp_body.outputHelp(writer);
126 }
127 writer.unindent();
128 }
129
130 /**
131 * Implementation of equals that is based on the values
132 * of the fields of the object. Thus, two objects
133 * created with identical parameters will be equal.
134 */
135 public boolean equals(java.lang.Object obj) {
136 if (obj == null) return false;
137 if ((obj.getClass() != this.getClass()) || (obj.hashCode() != this.hashCode())) {
138 return false;
139 } else {
140 InnerClassDef casted = (InnerClassDef) obj;
141 if (! (getMav().equals(casted.getMav()))) return false;
142 if (! (getName().equals(casted.getName()))) return false;
143 if (this.getTypeParameters().length != casted.getTypeParameters().length) return false;
144 for (int i = 0; i < getTypeParameters().length; i++) if (! getTypeParameters()[i].equals(casted.getTypeParameters()[i])) return false;
145 if (! (getSuperclass().equals(casted.getSuperclass()))) return false;
146 if (this.getInterfaces().length != casted.getInterfaces().length) return false;
147 for (int i = 0; i < getInterfaces().length; i++) if (! getInterfaces()[i].equals(casted.getInterfaces()[i])) return false;
148 if (! (getBody().equals(casted.getBody()))) return false;
149 return true;
150 }
151 }
152
153 /**
154 * Implementation of hashCode that is consistent with
155 * equals. The value of the hashCode is formed by
156 * XORing the hashcode of the class object with
157 * the hashcodes of all the fields of the object.
158 */
159 protected int generateHashCode() {
160 int code = getClass().hashCode();
161 code ^= 0;
162 code ^= getMav().hashCode();
163 code ^= getName().hashCode();
164 for (int i = 0; i < getTypeParameters().length; i++) code ^= getTypeParameters()[i].hashCode();
165 code ^= getSuperclass().hashCode();
166 for (int i = 0; i < getInterfaces().length; i++) code ^= getInterfaces()[i].hashCode();
167 code ^= getBody().hashCode();
168 return code;
169 }
170 }