aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/couscous/ast/InterfaceNode.java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-02-28 11:36:25 +0000
committerMichael Williamson <mike@zwobble.org>2016-02-28 11:36:25 +0000
commit4e4f98062c07afdeef14d4031ca69668649e5873 (patch)
tree6415aea98dc33ab50c490fbb3f812412f6dad8f0 /src/main/java/org/zwobble/couscous/ast/InterfaceNode.java
parentc588167505864bece6cbb2dc68814f7d967d9a6a (diff)
Introduce InterfaceNode
Diffstat (limited to 'src/main/java/org/zwobble/couscous/ast/InterfaceNode.java')
-rw-r--r--src/main/java/org/zwobble/couscous/ast/InterfaceNode.java81
1 files changed, 81 insertions, 0 deletions
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<TypeName> superTypes,
+ List<MethodNode> methods)
+ {
+ return new InterfaceNode(name, superTypes, methods);
+ }
+
+ private final TypeName name;
+ private final Set<TypeName> superTypes;
+ private final List<MethodNode> methods;
+
+ private InterfaceNode(
+ TypeName name,
+ Set<TypeName> superTypes,
+ List<MethodNode> methodNodes)
+ {
+ this.name = name;
+ this.superTypes = superTypes;
+ methods = methodNodes;
+ }
+
+ @Override
+ public TypeName getName() {
+ return name;
+ }
+
+ @Override
+ public Set<TypeName> getSuperTypes() {
+ return superTypes;
+ }
+
+ @Override
+ public List<MethodNode> getMethods() {
+ return methods;
+ }
+
+ @Override
+ public <T> T accept(NodeMapper<T> 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;
+ }
+}