ASTIdentifier.java

package edu.udel.cis.vsl.tass.front.minimp.ast.misc;

import edu.udel.cis.vsl.tass.util.Source;

public class ASTIdentifier {
  private String idName;
  private Source source;

  public ASTIdentifier(String name) {
    idName = name;
  }

  public String toString() {
    return idName;
  }

  public Source source() {
    return this.source;
  }

  public void setSource(Source source) {
    if (source == null) {
      throw new NullPointerException("Null source.");
    }
    this.source = source;
  }

  public void setText(String text) {
    this.source.setText(text);
  }

  public int hashCode() {
    return this.idName.hashCode() + this.source.hashCode();
  }

  public boolean equals(Object that) {
    if (that instanceof ASTIdentifier) {
      ASTIdentifier temp = (ASTIdentifier) that;
      if (this.idName.equals(temp.idName)) {
        if (this.source.equals(temp.source)) {
          return true;
        }
      }
    }
    return false;
  }
}