| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| KualiDecimal |
|
| 1.0;1 |
| 1 | /* | |
| 2 | * Copyright 2005-2007 The Kuali Foundation | |
| 3 | * | |
| 4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.opensource.org/licenses/ecl2.php | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | package org.kuali.rice.kns.util; | |
| 17 | ||
| 18 | import java.math.BigDecimal; | |
| 19 | ||
| 20 | /** | |
| 21 | * This class is a wrapper around java.math.BigDecimal. It exposes the only the | |
| 22 | * needed functionality of BigDecimal and uses a standard SCALE of 2 and | |
| 23 | * ROUND_BEHAVIOR of BigDecimal.ROUND_HALF_UP | |
| 24 | * | |
| 25 | * Members of this class are, like BigDecimal, immutable; even methods which | |
| 26 | * might be expected to change the value (like setScale, for example) actually | |
| 27 | * just return a new instance with the new value. | |
| 28 | */ | |
| 29 | 0 | public class KualiDecimal extends AbstractKualiDecimal<KualiDecimal> { |
| 30 | ||
| 31 | private static final long serialVersionUID = 899528391396696786L; | |
| 32 | ||
| 33 | 0 | public static final KualiDecimal ZERO = new KualiDecimal(BigDecimal.ZERO); |
| 34 | ||
| 35 | public static final int SCALE = 2; | |
| 36 | ||
| 37 | /** | |
| 38 | * No-arg constructor for serialization purposes | |
| 39 | */ | |
| 40 | 0 | public KualiDecimal() { |
| 41 | 0 | } |
| 42 | ||
| 43 | /** | |
| 44 | * This is the base constructor, used by constructors that take other types | |
| 45 | * | |
| 46 | * @param value | |
| 47 | * String containing numeric value | |
| 48 | * @throws IllegalArgumentException | |
| 49 | * if the given String is null | |
| 50 | */ | |
| 51 | public KualiDecimal(String value) { | |
| 52 | 0 | super(value, SCALE); |
| 53 | 0 | } |
| 54 | ||
| 55 | public KualiDecimal(int value) { | |
| 56 | 0 | super(value, SCALE); |
| 57 | 0 | } |
| 58 | ||
| 59 | public KualiDecimal(double value) { | |
| 60 | 0 | super(value, SCALE); |
| 61 | 0 | } |
| 62 | ||
| 63 | public KualiDecimal(BigDecimal value) { | |
| 64 | 0 | super(value, SCALE); |
| 65 | 0 | } |
| 66 | ||
| 67 | public KualiDecimal setScale() { | |
| 68 | 0 | return new KualiDecimal(value, SCALE); |
| 69 | } | |
| 70 | ||
| 71 | protected KualiDecimal(String value, int scale) { | |
| 72 | 0 | super(value, scale); |
| 73 | 0 | } |
| 74 | ||
| 75 | protected KualiDecimal(int value, int scale) { | |
| 76 | 0 | super(value, scale); |
| 77 | 0 | } |
| 78 | ||
| 79 | protected KualiDecimal(double value, int scale) { | |
| 80 | 0 | super(value, scale); |
| 81 | 0 | } |
| 82 | ||
| 83 | protected KualiDecimal(BigDecimal value, int scale) { | |
| 84 | 0 | super(value, scale); |
| 85 | 0 | } |
| 86 | ||
| 87 | @Override | |
| 88 | protected KualiDecimal newInstance(String value) { | |
| 89 | 0 | return new KualiDecimal(value); |
| 90 | } | |
| 91 | ||
| 92 | @Override | |
| 93 | protected KualiDecimal newInstance(double value) { | |
| 94 | 0 | return new KualiDecimal(value); |
| 95 | } | |
| 96 | ||
| 97 | @Override | |
| 98 | protected KualiDecimal newInstance(double value, int scale) { | |
| 99 | 0 | return new KualiDecimal(value, scale); |
| 100 | } | |
| 101 | ||
| 102 | @Override | |
| 103 | protected KualiDecimal newInstance(BigDecimal value) { | |
| 104 | 0 | return new KualiDecimal(value); |
| 105 | } | |
| 106 | ||
| 107 | @Override | |
| 108 | protected KualiDecimal newInstance(BigDecimal value, int scale) { | |
| 109 | 0 | return new KualiDecimal(value, scale); |
| 110 | } | |
| 111 | ||
| 112 | } |