package annotations.el;

import java.util.LinkedHashMap;

import annotations.util.coll.VivifyingMap;

/**
 * An {@link ATypeElement} that also stores an un-annotated type. This is useful for cast
 * insertion or receiver insertion.
 */
public class ATypeElementWithType extends ATypeElement {

    static <K extends /*@ReadOnly*/ Object> VivifyingMap<K, ATypeElementWithType> newVivifyingLHMap_AITTE() {
        return new VivifyingMap<K, ATypeElementWithType>(
                new LinkedHashMap<K, ATypeElementWithType>()) {
            @Override
            public  ATypeElementWithType createValueFor(K k) /*@ReadOnly*/ {
                return new ATypeElementWithType(k);
            }

            @Override
            public boolean subPrune(ATypeElementWithType v) /*@ReadOnly*/ {
                return v.prune();
            }
        };
    }

    /**
     * The un-annotated type to cast to.
     */
    private String type;

    ATypeElementWithType(Object description) {
        super(description);
    }

    /**
     * Gets the un-annotated type to cast to.
     *
     * @return The un-annotated type to cast to.
     */
    public String getType() {
        return type;
    }

    /**
     * Sets the unqualified type to cast to.
     *
     * @param type The unqualified type to cast to.
     */
    public void setType(String type) {
        this.type = type;
    }

    @Override
    public boolean equals(Object o) {
      if (o instanceof ATypeElementWithType) {
          ATypeElementWithType other = (ATypeElementWithType) o;
        return super.equals(other) && this.type.equals(other.type);
      } else {
        return false;
      }
    }

    @Override
    public int hashCode() {
      return super.hashCode() + type.hashCode();
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("AInsertTypecastTypeElement: ");
        sb.append('\t');
        sb.append(super.toString());
        sb.append("type: " + type);
        return sb.toString();
    }
}

@@ -881,35 +881,24 @@
 notated type
- to cast to
 .%0A     */%0A  
@@ -1040,35 +1040,24 @@
 notated type
- to cast to
 .%0A     *%0A   
@@ -1085,35 +1085,24 @@
 notated type
- to cast to
 .%0A     */%0A  
@@ -1187,33 +1187,23 @@
 e un
-qualified type to cast to
+-annotated type
 .%0A  
@@ -1236,33 +1236,23 @@
 e un
-qualified type to cast to
+-annotated type
 .%0A  

Update comments.