| 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 Decimal64 extends Number |
| 27 |
{ |
| 28 |
private final BigDecimal _underlying; |
| 29 |
private final long _bits; |
| 30 |
|
| 31 |
public Decimal64(BigDecimal underlying) |
| 32 |
{ |
| 33 |
_underlying = underlying; |
| 34 |
_bits = calculateBits(underlying); |
| 35 |
|
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
public Decimal64(final long bits) |
| 40 |
{ |
| 41 |
_bits = bits; |
| 42 |
_underlying = calculateBigDecimal(bits); |
| 43 |
} |
| 44 |
|
| 45 |
static BigDecimal calculateBigDecimal(final long bits) |
| 46 |
{ |
| 47 |
return BigDecimal.ZERO; |
| 48 |
} |
| 49 |
|
| 50 |
static long calculateBits(final BigDecimal underlying) |
| 51 |
{ |
| 52 |
return 0l; // TODO |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
@Override |
| 57 |
public int intValue() |
| 58 |
{ |
| 59 |
return _underlying.intValue(); |
| 60 |
} |
| 61 |
|
| 62 |
@Override |
| 63 |
public long longValue() |
| 64 |
{ |
| 65 |
return _underlying.longValue(); |
| 66 |
} |
| 67 |
|
| 68 |
@Override |
| 69 |
public float floatValue() |
| 70 |
{ |
| 71 |
return _underlying.floatValue(); |
| 72 |
} |
| 73 |
|
| 74 |
@Override |
| 75 |
public double doubleValue() |
| 76 |
{ |
| 77 |
return _underlying.doubleValue(); |
| 78 |
} |
| 79 |
|
| 80 |
public long getBits() |
| 81 |
{ |
| 82 |
return _bits; |
| 83 |
} |
| 84 |
|
| 85 |
@Override |
| 86 |
public boolean equals(final Object o) |
| 87 |
{ |
| 88 |
if (this == o) |
| 89 |
{ |
| 90 |
return true; |
| 91 |
} |
| 92 |
if (o == null || getClass() != o.getClass()) |
| 93 |
{ |
| 94 |
return false; |
| 95 |
} |
| 96 |
|
| 97 |
final Decimal64 decimal64 = (Decimal64) o; |
| 98 |
|
| 99 |
if (_bits != decimal64._bits) |
| 100 |
{ |
| 101 |
return false; |
| 102 |
} |
| 103 |
|
| 104 |
return true; |
| 105 |
} |
| 106 |
|
| 107 |
@Override |
| 108 |
public int hashCode() |
| 109 |
{ |
| 110 |
return (int) (_bits ^ (_bits >>> 32)); |
| 111 |
} |
| 112 |
} |