/* This file was generated with JastAdd2 (http://jastadd.org) version jenkins-JastAdd2-430 */
package AST;

/**
 * @production PackageName : {@link Name};
 * @ast node
 * @declaredat JavaDemoNames.ast:18
 */
public class PackageName extends Name implements Cloneable {
  /**
   * @apilevel internal
   */
  @SuppressWarnings({"unchecked", "cast"})
  public PackageName clone() throws CloneNotSupportedException {
    PackageName node = (PackageName) super.clone();
    node.qualifiedLookupType_String_visited = null;
    node.qualifiedLookupType_String_values = null;
    node.predKind_visited = -1;
    node.predKind_computed = false;
    node.predKind_value = null;
    node.qualifiedHasPackage_String_visited = null;
    node.qualifiedHasPackage_String_values = null;
    node.in$Circle(false);
    node.is$Final(false);
    return node;
  }
  /**
   * @apilevel internal
   */
  @SuppressWarnings({"unchecked", "cast"})
  public PackageName copy() {
    try {
      PackageName node = (PackageName) clone();
      node.parent = null;
      if(children != null) {
        node.children = (ASTNode[]) children.clone();
      }
      return node;
    } catch (CloneNotSupportedException e) {
      throw new Error("Error: clone not supported for " + getClass().getName());
    }
  }
  /**
   * Create a deep copy of the AST subtree at this node.
   * The copy is dangling, i.e. has no parent.
   * @return dangling copy of the subtree at this node
   * @apilevel low-level
   */
  @SuppressWarnings({"unchecked", "cast"})
  public PackageName fullCopy() {
    PackageName tree = (PackageName) copy();
    if (children != null) {
      for (int i = 0; i < children.length; ++i) {
        ASTNode child = (ASTNode) children[i];
        if(child != null) {
          child = child.fullCopy();
          tree.setChild(child, i);
        }
      }
    }
    return tree;
  }
  /**
   * 
   * @ast method
   * 
   */

  public PackageName() {
    super();
  }
  /**
   * 
     * Initializes the child array to the correct size.
     * Initializes List and Opt nta children.
     * @apilevel internal
     * @ast method
     
   * @ast method
   * 
   */

  public void init$Children() {
  }
  /**
   * 
   * @ast method
   * 
   */

  public PackageName(String p0) {
    setname(p0);
  }
  /**
   * 
     * @apilevel low-level
     
   * @ast method
   * 
   */

  protected int numChildren() {
    return 0;
  }
  /**
   * 
     * @apilevel internal
     
   * @ast method
   * 
   */

  public boolean mayHaveRewrite() {
    return false;
  }
  /**
   * 
      * @apilevel low-level
      
   * @ast method
   * 
   */

  public void flushCache() {
    super.flushCache();
        qualifiedLookupType_String_visited = null;
    qualifiedLookupType_String_values = null;
    predKind_visited = -1;
    predKind_computed = false;
    predKind_value = null;
    qualifiedHasPackage_String_visited = null;
    qualifiedHasPackage_String_values = null;
  }
  /**
   * 
      * @apilevel internal
      
   * @ast method
   * 
   */

  public void flushCollectionCache() {
    super.flushCollectionCache();
      }
  /**
   * 
     * Replaces the lexeme name.
     * @param value The new value for the lexeme name.
     * @apilevel high-level
     
   * @ast method
   * 
   */

  public void setname(String value) {
    tokenString_name = value;
  }
  /**
   * 
     * Retrieves the value for the lexeme name.
     * @return The value for the lexeme name.
     * @apilevel high-level
     
   * @ast method
   * 
   */

  public String getname() {
    return tokenString_name != null ? tokenString_name : "";
  }
  /**
   * @apilevel internal
   */
  protected java.util.Map qualifiedLookupType_String_visited;
  protected java.util.Map qualifiedLookupType_String_values;
  /**
   * @attribute syn
   * @aspect JavaDemoNames
   * @declaredat JavaDemoNames.jrag:127
   */

  public ClassDecl qualifiedLookupType(String typeName) {
    Object _parameters = typeName;
    if(qualifiedLookupType_String_visited == null) qualifiedLookupType_String_visited = new java.util.HashMap(4);
    if(qualifiedLookupType_String_values == null) qualifiedLookupType_String_values = new java.util.HashMap(4);
    

    
if(qualifiedLookupType_String_values.containsKey(_parameters)) {
  return (ClassDecl)qualifiedLookupType_String_values.get(_parameters); 
}

    ASTNode$State state = state();
    if (Integer.valueOf(state().boundariesCrossed).equals(qualifiedLookupType_String_visited.get(_parameters))) {
      throw new RuntimeException("Circular definition of attr: qualifiedLookupType in class: ast.AST.SynDecl");
    }
                
    qualifiedLookupType_String_visited.put(_parameters, Integer.valueOf(state().boundariesCrossed));
          
    int num = state.boundariesCrossed;
    boolean isFinal = this.is$Final();
    ClassDecl qualifiedLookupType_String_value = qualifiedLookupType_compute(typeName);
      if(isFinal && num == state().boundariesCrossed){ qualifiedLookupType_String_values.put(_parameters, qualifiedLookupType_String_value); }
    qualifiedLookupType_String_visited.remove(_parameters);
        return qualifiedLookupType_String_value;
  }
  /**
   * @apilevel internal
   */
  private ClassDecl qualifiedLookupType_compute(String typeName) {  return lookupCanonical(getname(), typeName);  }
  /**
   * @apilevel internal
   */
  protected int predKind_visited = -1;
  /**
   * @apilevel internal
   */
  protected boolean predKind_computed = false;
  /**
   * @apilevel internal
   */
  protected Kind predKind_value;
  /**
   * @attribute syn
   * @aspect JavaDemoNames
   * @declaredat JavaDemoNames.jrag:156
   */

  public Kind predKind() {
    

    
if(predKind_computed) {
  return predKind_value;
}

    ASTNode$State state = state();
    if (predKind_visited == state().boundariesCrossed) {
      throw new RuntimeException("Circular definition of attr: predKind in class: ast.AST.SynDecl");
    }
          
    predKind_visited = state().boundariesCrossed;
      
    int num = state.boundariesCrossed;
    boolean isFinal = this.is$Final();
    predKind_value = predKind_compute();
      if(isFinal && num == state().boundariesCrossed){ predKind_computed = true; }
    predKind_visited = -1;
        return predKind_value;
  }
  /**
   * @apilevel internal
   */
  private Kind predKind_compute() {  return Kind.PACKAGE_NAME;  }
  /**
   * @apilevel internal
   */
  protected java.util.Map qualifiedHasPackage_String_visited;
  protected java.util.Map qualifiedHasPackage_String_values;
  /**
   * @attribute syn
   * @aspect JavaDemoNames
   * @declaredat JavaDemoNames.jrag:194
   */

  public boolean qualifiedHasPackage(String name) {
    Object _parameters = name;
    if(qualifiedHasPackage_String_visited == null) qualifiedHasPackage_String_visited = new java.util.HashMap(4);
    if(qualifiedHasPackage_String_values == null) qualifiedHasPackage_String_values = new java.util.HashMap(4);
    

    
if(qualifiedHasPackage_String_values.containsKey(_parameters)) {
  return ((Boolean)qualifiedHasPackage_String_values.get(_parameters)).booleanValue(); 
}

    ASTNode$State state = state();
    if (Integer.valueOf(state().boundariesCrossed).equals(qualifiedHasPackage_String_visited.get(_parameters))) {
      throw new RuntimeException("Circular definition of attr: qualifiedHasPackage in class: ast.AST.SynDecl");
    }
                
    qualifiedHasPackage_String_visited.put(_parameters, Integer.valueOf(state().boundariesCrossed));
          
    int num = state.boundariesCrossed;
    boolean isFinal = this.is$Final();
    boolean qualifiedHasPackage_String_value = qualifiedHasPackage_compute(name);
      if(isFinal && num == state().boundariesCrossed){ qualifiedHasPackage_String_values.put(_parameters, Boolean.valueOf(qualifiedHasPackage_String_value)); }
    qualifiedHasPackage_String_visited.remove(_parameters);
        return qualifiedHasPackage_String_value;
  }
  /**
   * @apilevel internal
   */
  private boolean qualifiedHasPackage_compute(String name) {  return hasPackage(getname() + '.' + name);  }
  /**
   * @apilevel internal
   */
  public ASTNode rewriteTo() {    return super.rewriteTo();
  }}
