1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.johnzon.core; |
20 | |
|
21 | |
import java.math.BigDecimal; |
22 | |
import java.math.BigInteger; |
23 | |
|
24 | |
import javax.json.JsonNumber; |
25 | |
|
26 | |
final class JsonLongImpl implements JsonNumber { |
27 | |
private final long value; |
28 | |
|
29 | 9194 | JsonLongImpl(final long value) { |
30 | 9194 | this.value = value; |
31 | 9194 | } |
32 | |
|
33 | |
@Override |
34 | |
public boolean isIntegral() { |
35 | 0 | return true; |
36 | |
} |
37 | |
|
38 | |
@Override |
39 | |
public int intValue() { |
40 | 18 | return (int) value; |
41 | |
} |
42 | |
|
43 | |
@Override |
44 | |
public int intValueExact() { |
45 | 0 | return intValue(); |
46 | |
} |
47 | |
|
48 | |
@Override |
49 | |
public long longValue() { |
50 | 3 | return value; |
51 | |
} |
52 | |
|
53 | |
@Override |
54 | |
public long longValueExact() { |
55 | 0 | return value; |
56 | |
} |
57 | |
|
58 | |
@Override |
59 | |
public BigInteger bigIntegerValue() { |
60 | 0 | return new BigInteger(toString()); |
61 | |
} |
62 | |
|
63 | |
@Override |
64 | |
public BigInteger bigIntegerValueExact() { |
65 | 0 | return bigIntegerValue(); |
66 | |
} |
67 | |
|
68 | |
@Override |
69 | |
public double doubleValue() { |
70 | 0 | return value; |
71 | |
} |
72 | |
|
73 | |
@Override |
74 | |
public BigDecimal bigDecimalValue() { |
75 | 0 | return new BigDecimal(toString()); |
76 | |
} |
77 | |
|
78 | |
@Override |
79 | |
public ValueType getValueType() { |
80 | 2 | return ValueType.NUMBER; |
81 | |
} |
82 | |
|
83 | |
@Override |
84 | |
public String toString() { |
85 | 13 | return Long.toString(value); |
86 | |
} |
87 | |
|
88 | |
@Override |
89 | |
public int hashCode() { |
90 | 0 | return (int) value; |
91 | |
} |
92 | |
|
93 | |
@Override |
94 | |
public boolean equals(final Object obj) { |
95 | 0 | return JsonNumber.class.isInstance(obj) && JsonNumber.class.cast(obj).longValue() == value; |
96 | |
} |
97 | |
} |