From 4e4f98062c07afdeef14d4031ca69668649e5873 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 28 Feb 2016 11:36:25 +0000 Subject: Introduce InterfaceNode --- .../org/zwobble/couscous/ast/InterfaceNode.java | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/main/java/org/zwobble/couscous/ast/InterfaceNode.java (limited to 'src/main/java/org/zwobble/couscous/ast/InterfaceNode.java') diff --git a/src/main/java/org/zwobble/couscous/ast/InterfaceNode.java b/src/main/java/org/zwobble/couscous/ast/InterfaceNode.java new file mode 100644 index 0000000..09d2d3a --- /dev/null +++ b/src/main/java/org/zwobble/couscous/ast/InterfaceNode.java @@ -0,0 +1,81 @@ +package org.zwobble.couscous.ast; + +import org.zwobble.couscous.ast.visitors.NodeMapper; + +import java.util.List; +import java.util.Set; + +public class InterfaceNode implements TypeNode { + public static InterfaceNode declareInterface( + TypeName name, + Set superTypes, + List methods) + { + return new InterfaceNode(name, superTypes, methods); + } + + private final TypeName name; + private final Set superTypes; + private final List methods; + + private InterfaceNode( + TypeName name, + Set superTypes, + List methodNodes) + { + this.name = name; + this.superTypes = superTypes; + methods = methodNodes; + } + + @Override + public TypeName getName() { + return name; + } + + @Override + public Set getSuperTypes() { + return superTypes; + } + + @Override + public List getMethods() { + return methods; + } + + @Override + public T accept(NodeMapper visitor) { + // TODO: implement this + return null; + } + + @Override + public String toString() { + return "InterfaceNode(" + + "name=" + name + + ", superTypes=" + superTypes + + ", methods=" + methods + + ')'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + InterfaceNode that = (InterfaceNode) o; + + if (!name.equals(that.name)) return false; + if (!superTypes.equals(that.superTypes)) return false; + return methods.equals(that.methods); + + } + + @Override + public int hashCode() { + int result = name.hashCode(); + result = 31 * result + superTypes.hashCode(); + result = 31 * result + methods.hashCode(); + return result; + } +} -- cgit v1.2.3