001    package edu.rice.cs.javalanglevels.tree;
002    
003    import edu.rice.cs.javalanglevels.SourceInfo;
004    
005    /**
006     * Class SimpleAnonymousClassInstantiation, 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 SimpleAnonymousClassInstantiation extends AnonymousClassInstantiation {
011    
012      /**
013       * Constructs a SimpleAnonymousClassInstantiation.
014       * @throws java.lang.IllegalArgumentException  If any parameter to the constructor is null.
015       */
016      public SimpleAnonymousClassInstantiation(SourceInfo in_sourceInfo, Type in_type, ParenthesizedExpressionList in_arguments, BracedBody in_body) {
017        super(in_sourceInfo, in_type, in_arguments, in_body);
018      }
019    
020    
021      public <RetType> RetType visit(JExpressionIFVisitor<RetType> visitor) { return visitor.forSimpleAnonymousClassInstantiation(this); }
022      public void visit(JExpressionIFVisitor_void visitor) { visitor.forSimpleAnonymousClassInstantiation(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("SimpleAnonymousClassInstantiation" + ":");
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("type = ");
056        Type temp_type = getType();
057        if (temp_type == null) {
058          writer.print("null");
059        } else {
060          temp_type.outputHelp(writer);
061        }
062    
063        writer.startLine("");
064        writer.print("arguments = ");
065        ParenthesizedExpressionList temp_arguments = getArguments();
066        if (temp_arguments == null) {
067          writer.print("null");
068        } else {
069          temp_arguments.outputHelp(writer);
070        }
071    
072        writer.startLine("");
073        writer.print("body = ");
074        BracedBody temp_body = getBody();
075        if (temp_body == null) {
076          writer.print("null");
077        } else {
078          temp_body.outputHelp(writer);
079        }
080        writer.unindent();
081      }
082    
083      /**
084       * Implementation of equals that is based on the values
085       * of the fields of the object. Thus, two objects 
086       * created with identical parameters will be equal.
087       */
088      public boolean equals(java.lang.Object obj) {
089        if (obj == null) return false;
090        if ((obj.getClass() != this.getClass()) || (obj.hashCode() != this.hashCode())) {
091          return false;
092        } else {
093          SimpleAnonymousClassInstantiation casted = (SimpleAnonymousClassInstantiation) obj;
094          if (! (getType().equals(casted.getType()))) return false;
095          if (! (getArguments().equals(casted.getArguments()))) return false;
096          if (! (getBody().equals(casted.getBody()))) return false;
097          return true;
098        }
099      }
100    
101      /**
102       * Implementation of hashCode that is consistent with
103       * equals. The value of the hashCode is formed by
104       * XORing the hashcode of the class object with
105       * the hashcodes of all the fields of the object.
106       */
107      protected int generateHashCode() {
108        int code = getClass().hashCode();
109        code ^= 0;
110        code ^= getType().hashCode();
111        code ^= getArguments().hashCode();
112        code ^= getBody().hashCode();
113        return code;
114      }
115    }