KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > engine > TypedValue


1 //$Id: TypedValue.java,v 1.5 2005/05/02 14:32:42 oneovthafew Exp $
2
package org.hibernate.engine;
3
4 import java.io.Serializable JavaDoc;
5
6 import org.hibernate.EntityMode;
7 import org.hibernate.type.Type;
8
9 /**
10  * An ordered pair of a value and its Hibernate type.
11  *
12  * @see org.hibernate.type.Type
13  * @author Gavin King
14  */

15 public final class TypedValue implements Serializable JavaDoc {
16     private final Type type;
17     private final Object JavaDoc value;
18     private final EntityMode entityMode;
19
20     public TypedValue(Type type, Object JavaDoc value, EntityMode entityMode) {
21         this.type = type;
22         this.value=value;
23         this.entityMode = entityMode;
24     }
25
26     public Object JavaDoc getValue() {
27         return value;
28     }
29
30     public Type getType() {
31         return type;
32     }
33
34     public String JavaDoc toString() {
35         return value==null ? "null" : value.toString();
36     }
37
38     public int hashCode() {
39         //int result = 17;
40
//result = 37 * result + type.hashCode();
41
//result = 37 * result + ( value==null ? 0 : value.hashCode() );
42
//return result;
43
return value==null ? 0 : type.getHashCode(value, entityMode);
44     }
45
46     public boolean equals(Object JavaDoc other) {
47         if ( !(other instanceof TypedValue) ) return false;
48         TypedValue that = (TypedValue) other;
49         /*return that.type.equals(type) &&
50             EqualsHelper.equals(that.value, value);*/

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