1 package org.hibernate.engine; 3 4 import java.io.Serializable ; 5 6 import org.hibernate.EntityMode; 7 import org.hibernate.type.Type; 8 9 15 public final class TypedValue implements Serializable { 16 private final Type type; 17 private final Object value; 18 private final EntityMode entityMode; 19 20 public TypedValue(Type type, Object value, EntityMode entityMode) { 21 this.type = type; 22 this.value=value; 23 this.entityMode = entityMode; 24 } 25 26 public Object getValue() { 27 return value; 28 } 29 30 public Type getType() { 31 return type; 32 } 33 34 public String toString() { 35 return value==null ? "null" : value.toString(); 36 } 37 38 public int hashCode() { 39 return value==null ? 0 : type.getHashCode(value, entityMode); 44 } 45 46 public boolean equals(Object other) { 47 if ( !(other instanceof TypedValue) ) return false; 48 TypedValue that = (TypedValue) other; 49 51 return type.getReturnedClass() == that.type.getReturnedClass() && 52 type.isEqual(that.value, value, entityMode); 53 } 54 55 } 56 57 58 59 60 61 | Popular Tags |