1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.core.api.criteria; |
17 | |
|
18 | |
import java.math.BigInteger; |
19 | |
import java.util.concurrent.atomic.AtomicInteger; |
20 | |
import java.util.concurrent.atomic.AtomicLong; |
21 | |
|
22 | |
import javax.xml.bind.annotation.XmlAccessType; |
23 | |
import javax.xml.bind.annotation.XmlAccessorType; |
24 | |
import javax.xml.bind.annotation.XmlRootElement; |
25 | |
import javax.xml.bind.annotation.XmlType; |
26 | |
import javax.xml.bind.annotation.XmlValue; |
27 | |
|
28 | |
import org.apache.commons.lang.builder.EqualsBuilder; |
29 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
30 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
31 | |
import org.apache.commons.lang.mutable.MutableLong; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | 2 | @XmlRootElement(name = CriteriaIntegerValue.Constants.ROOT_ELEMENT_NAME) |
41 | |
@XmlAccessorType(XmlAccessType.NONE) |
42 | |
@XmlType(name = CriteriaIntegerValue.Constants.TYPE_NAME) |
43 | |
public final class CriteriaIntegerValue implements CriteriaValue<BigInteger> { |
44 | |
|
45 | |
@XmlValue |
46 | |
private BigInteger value; |
47 | |
|
48 | 34 | CriteriaIntegerValue() { |
49 | 34 | this.value = null; |
50 | 34 | } |
51 | |
|
52 | 12 | CriteriaIntegerValue(BigInteger value) { |
53 | 12 | validateValue(value); |
54 | 12 | this.value = value; |
55 | 12 | } |
56 | |
|
57 | 1 | CriteriaIntegerValue(Short value) { |
58 | 1 | validateValue(value); |
59 | 1 | this.value = BigInteger.valueOf(value.longValue()); |
60 | 1 | } |
61 | |
|
62 | 52 | CriteriaIntegerValue(Integer value) { |
63 | 52 | validateValue(value); |
64 | 52 | this.value = BigInteger.valueOf(value.longValue()); |
65 | 52 | } |
66 | |
|
67 | 0 | CriteriaIntegerValue(AtomicInteger value) { |
68 | 0 | validateValue(value); |
69 | 0 | this.value = BigInteger.valueOf(value.longValue()); |
70 | 0 | } |
71 | |
|
72 | 1 | CriteriaIntegerValue(Long value) { |
73 | 1 | validateValue(value); |
74 | 1 | this.value = BigInteger.valueOf(value.longValue()); |
75 | 1 | } |
76 | |
|
77 | 0 | CriteriaIntegerValue(AtomicLong value) { |
78 | 0 | validateValue(value); |
79 | 0 | this.value = BigInteger.valueOf(value.longValue()); |
80 | 0 | } |
81 | |
|
82 | 0 | CriteriaIntegerValue(MutableLong value) { |
83 | 0 | validateValue(value); |
84 | 0 | this.value = BigInteger.valueOf(value.longValue()); |
85 | 0 | } |
86 | |
|
87 | |
private static void validateValue(Object value) { |
88 | 66 | if (value == null) { |
89 | 0 | throw new IllegalArgumentException("Value cannot be null."); |
90 | |
} |
91 | 66 | } |
92 | |
|
93 | |
@Override |
94 | |
public BigInteger getValue() { |
95 | 2 | return value; |
96 | |
} |
97 | |
|
98 | |
@Override |
99 | |
public int hashCode() { |
100 | 0 | return HashCodeBuilder.reflectionHashCode(this); |
101 | |
} |
102 | |
|
103 | |
@Override |
104 | |
public boolean equals(Object obj) { |
105 | 34 | return EqualsBuilder.reflectionEquals(obj, this); |
106 | |
} |
107 | |
|
108 | |
@Override |
109 | |
public String toString() { |
110 | 0 | return ToStringBuilder.reflectionToString(this); |
111 | |
} |
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | 0 | static class Constants { |
117 | |
final static String ROOT_ELEMENT_NAME = "integerValue"; |
118 | |
final static String TYPE_NAME = "CriteriaIntegerValueType"; |
119 | |
} |
120 | |
|
121 | |
} |