]> gerrit.simantics Code Review - simantics/platform.git/blob - 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
1 package org.simantics.scl.compiler.dynamic;
2
3 import org.simantics.scl.compiler.types.Type;
4
5 public class SafeDynamic {
6     public final Type type_;
7     public final Object value;
8     
9     public SafeDynamic(Type type_, Object value) {
10         this.type_ = type_;
11         this.value = value;
12     }
13
14     public String toString() {
15         return new StringBuilder().append("(SafeDynamic").append(" ").append((Object)this.type_).append(" ").append(this.value).append(")").toString();
16     }
17     
18     public boolean equals(Object other) {
19         if(this == other)
20             return true;
21         if(other == null || !other.getClass().equals(SafeDynamic.class))
22             return false;
23         SafeDynamic dyn = (SafeDynamic)other;
24         return type_.equals(dyn.type_) && (value == null ? dyn.value == null : value.equals(dyn.value));
25     }
26     
27     public int hashCode() {
28         return 31*type_.hashCode()+(value==null ? -957171758 : value.hashCode());
29     }
30 }