]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/dynamic/SafeDynamic.java
(refs #7767) SafeDynamic module
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / dynamic / SafeDynamic.java
diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/dynamic/SafeDynamic.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/dynamic/SafeDynamic.java
new file mode 100644 (file)
index 0000000..45c0710
--- /dev/null
@@ -0,0 +1,30 @@
+package org.simantics.scl.compiler.dynamic;
+
+import org.simantics.scl.compiler.types.Type;
+
+public class SafeDynamic {
+    public final Type type_;
+    public final Object value;
+    
+    public SafeDynamic(Type type_, Object value) {
+        this.type_ = type_;
+        this.value = value;
+    }
+
+    public String toString() {
+        return new StringBuilder().append("(SafeDynamic").append(" ").append((Object)this.type_).append(" ").append(this.value).append(")").toString();
+    }
+    
+    public boolean equals(Object other) {
+        if(this == other)
+            return true;
+        if(other == null || !other.getClass().equals(SafeDynamic.class))
+            return false;
+        SafeDynamic dyn = (SafeDynamic)other;
+        return type_.equals(dyn.type_) && (value == null ? dyn.value == null : value.equals(dyn.value));
+    }
+    
+    public int hashCode() {
+        return 31*type_.hashCode()+(value==null ? -957171758 : value.hashCode());
+    }
+}