Debian Codegraph @

proton-j/src/main/java/org/apache/qpid/proton/amqp/Decimal32.java

raw
1 /*
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 */
21
22 package org.apache.qpid.proton.amqp;
23
24 import java.math.BigDecimal;
25
26 public final class Decimal32 extends Number
27 {
28 private final BigDecimal _underlying;
29 private final int _bits;
30
31 public Decimal32(BigDecimal underlying)
32 {
33 _underlying = underlying;
34 _bits = calculateBits( underlying );
35 }
36
37 public Decimal32(final int bits)
38 {
39 _bits = bits;
40 _underlying = calculateBigDecimal(bits);
41 }
42
43 static int calculateBits(final BigDecimal underlying)
44 {
45 return 0; //TODO.
46 }
47
48 static BigDecimal calculateBigDecimal(int bits)
49 {
50 return BigDecimal.ZERO; // TODO
51 }
52
53
54 @Override
55 public int intValue()
56 {
57 return _underlying.intValue();
58 }
59
60 @Override
61 public long longValue()
62 {
63 return _underlying.longValue();
64 }
65
66 @Override
67 public float floatValue()
68 {
69 return _underlying.floatValue();
70 }
71
72 @Override
73 public double doubleValue()
74 {
75 return _underlying.doubleValue();
76 }
77
78 public int getBits()
79 {
80 return _bits;
81 }
82
83 @Override
84 public boolean equals(final Object o)
85 {
86 if (this == o)
87 {
88 return true;
89 }
90 if (o == null || getClass() != o.getClass())
91 {
92 return false;
93 }
94
95 final Decimal32 decimal32 = (Decimal32) o;
96
97 if (_bits != decimal32._bits)
98 {
99 return false;
100 }
101
102 return true;
103 }
104
105 @Override
106 public int hashCode()
107 {
108 return _bits;
109 }
110 }