]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/either/Right.java
(refs #7433) Make Either type available in Java
[simantics/platform.git] / bundles / org.simantics.scl.runtime / src / org / simantics / scl / runtime / either / Right.java
diff --git a/bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/either/Right.java b/bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/either/Right.java
new file mode 100644 (file)
index 0000000..27aeec9
--- /dev/null
@@ -0,0 +1,29 @@
+package org.simantics.scl.runtime.either;
+
+public class Right implements Either {
+    public final Object value;
+
+    public Right(Object value) {
+        this.value = value;
+    }
+    
+    @Override
+    public String toString() {
+        return "Right " + value;
+    }
+    
+    @Override
+    public boolean equals(Object obj) {
+        if(this == obj)
+            return true;
+        if(obj == null || obj.getClass() != getClass())
+            return false;
+        Right other = (Right)obj;
+        return value == null ? other.value == null : value.equals(other.value);
+    }
+    
+    @Override
+    public int hashCode() {
+        return 31 * (value == null ? 0 : value.hashCode()) + 13533;
+    }
+}