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