1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package fulmine.util.reference;
17
18
19
20
21
22
23
24 public final class Value<T>
25 {
26
27 private T value;
28
29 public Value()
30 {
31 super();
32 }
33
34 public Value(T value)
35 {
36 super();
37 set(value);
38 }
39
40 public T set(T value)
41 {
42 this.value = value;
43 return this.value;
44 }
45
46 public T get()
47 {
48 return this.value;
49 }
50
51 @Override
52 public String toString()
53 {
54 return this.value == null ? "null" : this.value.toString();
55 }
56
57 @Override
58 public int hashCode()
59 {
60 final int prime = 31;
61 int result = 1;
62 result = prime * result + ((value == null) ? 0 : value.hashCode());
63 return result;
64 }
65
66 @SuppressWarnings("unchecked")
67 @Override
68 public boolean equals(Object obj)
69 {
70 if (is.same(this, obj))
71 {
72 return true;
73 }
74 if (is.differentClass(this, obj))
75 {
76 return false;
77 }
78 final Value other = (Value) obj;
79 return is.eq(get(), other.get());
80 }
81 }