From 0a550c3bb4e624d76b3876e92a2bd0e235301fba Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 9 Apr 2016 14:21:48 +0100 Subject: Remove MethodTypeParameter and adjust Identifier generation --- .../ast/identifiers/ExtendedIdentifier.java | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/main/java/org/zwobble/couscous/ast/identifiers/ExtendedIdentifier.java (limited to 'src/main/java/org/zwobble/couscous/ast/identifiers/ExtendedIdentifier.java') diff --git a/src/main/java/org/zwobble/couscous/ast/identifiers/ExtendedIdentifier.java b/src/main/java/org/zwobble/couscous/ast/identifiers/ExtendedIdentifier.java new file mode 100644 index 0000000..407c6da --- /dev/null +++ b/src/main/java/org/zwobble/couscous/ast/identifiers/ExtendedIdentifier.java @@ -0,0 +1,50 @@ +package org.zwobble.couscous.ast.identifiers; + +import static org.zwobble.couscous.util.ExtraIterables.lazyAppend; + +public class ExtendedIdentifier implements Identifier { + private final Identifier parent; + private final String part; + private final IdentifierType type; + + ExtendedIdentifier(Identifier parent, String part, IdentifierType type) { + this.parent = parent; + this.part = part; + this.type = type; + } + + @Override + public Iterable getParts() { + return lazyAppend(parent.getParts(), new IdentifierPart(part, type)); + } + + @Override + public String toString() { + return "ExtendedIdentifier(" + + "parent=" + parent + + ", part='" + part + '\'' + + ", type=" + type + + ')'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ExtendedIdentifier that = (ExtendedIdentifier) o; + + if (!parent.equals(that.parent)) return false; + if (!part.equals(that.part)) return false; + return type == that.type; + + } + + @Override + public int hashCode() { + int result = parent.hashCode(); + result = 31 * result + part.hashCode(); + result = 31 * result + type.hashCode(); + return result; + } +} -- cgit v1.2.3