| 1 | /* | |
| 2 | * Copyright 2004 the original author or authors. | |
| 3 | * | |
| 4 | * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0 | |
| 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 com.ancientprogramming.fixedformat4j.format.data; | |
| 17 | ||
| 18 | import com.ancientprogramming.fixedformat4j.annotation.FixedFormatDecimal; | |
| 19 | ||
| 20 | import java.math.RoundingMode; | |
| 21 | ||
| 22 | import static com.ancientprogramming.fixedformat4j.annotation.FixedFormatDecimal.*; | |
| 23 | ||
| 24 | /** | |
| 25 | * Data object containing the exact same data as {@link FixedFormatDecimal} | |
| 26 | * | |
| 27 | * @author Jacob von Eyben - <a href="https://eybenconsult.com">https://eybenconsult.com</a> | |
| 28 | * @since 1.0.0 | |
| 29 | */ | |
| 30 | public class FixedFormatDecimalData { | |
| 31 | ||
| 32 | private int decimals; | |
| 33 | private boolean useDecimalDelimiter; | |
| 34 | private char decimalDelimiter; | |
| 35 | private RoundingMode roundingMode; | |
| 36 | | |
| 37 | public static final FixedFormatDecimalData DEFAULT = new FixedFormatDecimalData(DECIMALS, USE_DECIMAL_DELIMITER, DECIMAL_DELIMITER, RoundingMode.valueOf(ROUNDING_MODE)); | |
| 38 | ||
| 39 | /** | |
| 40 | * Creates a decimal data object. | |
| 41 | * | |
| 42 | * @param decimals the number of decimal places | |
| 43 | * @param useDecimalDelimiter {@code true} to include an explicit decimal delimiter in the field | |
| 44 | * @param decimalDelimiter the delimiter character used when {@code useDecimalDelimiter} is {@code true} | |
| 45 | * @param roundingMode the rounding mode applied when scaling the value | |
| 46 | */ | |
| 47 | public FixedFormatDecimalData(int decimals, boolean useDecimalDelimiter, char decimalDelimiter, RoundingMode roundingMode) { | |
| 48 | this.decimals = decimals; | |
| 49 | this.useDecimalDelimiter = useDecimalDelimiter; | |
| 50 | this.decimalDelimiter = decimalDelimiter; | |
| 51 | this.roundingMode = roundingMode; | |
| 52 | } | |
| 53 | ||
| 54 | /** | |
| 55 | * Returns the number of decimal places. | |
| 56 | * | |
| 57 | * @return the decimal count | |
| 58 | */ | |
| 59 | public int getDecimals() { | |
| 60 |
1
1. getDecimals : replaced int return with 0 for com/ancientprogramming/fixedformat4j/format/data/FixedFormatDecimalData::getDecimals → KILLED |
return decimals; |
| 61 | } | |
| 62 | ||
| 63 | /** | |
| 64 | * Returns whether an explicit decimal delimiter character is included in the formatted value. | |
| 65 | * | |
| 66 | * @return {@code true} if a delimiter is used; {@code false} for implicit decimals | |
| 67 | */ | |
| 68 | public boolean isUseDecimalDelimiter() { | |
| 69 |
2
1. isUseDecimalDelimiter : replaced boolean return with false for com/ancientprogramming/fixedformat4j/format/data/FixedFormatDecimalData::isUseDecimalDelimiter → KILLED 2. isUseDecimalDelimiter : replaced boolean return with true for com/ancientprogramming/fixedformat4j/format/data/FixedFormatDecimalData::isUseDecimalDelimiter → KILLED |
return useDecimalDelimiter; |
| 70 | } | |
| 71 | ||
| 72 | /** | |
| 73 | * Returns the decimal delimiter character. | |
| 74 | * | |
| 75 | * @return the delimiter character (only meaningful when {@link #isUseDecimalDelimiter()} is {@code true}) | |
| 76 | */ | |
| 77 | public char getDecimalDelimiter() { | |
| 78 |
1
1. getDecimalDelimiter : replaced char return with 0 for com/ancientprogramming/fixedformat4j/format/data/FixedFormatDecimalData::getDecimalDelimiter → KILLED |
return decimalDelimiter; |
| 79 | } | |
| 80 | ||
| 81 | /** | |
| 82 | * Returns the rounding mode applied when scaling to the configured number of decimal places. | |
| 83 | * | |
| 84 | * @return the {@link RoundingMode} | |
| 85 | */ | |
| 86 | public RoundingMode getRoundingMode() { | |
| 87 |
1
1. getRoundingMode : replaced return value with null for com/ancientprogramming/fixedformat4j/format/data/FixedFormatDecimalData::getRoundingMode → KILLED |
return roundingMode; |
| 88 | } | |
| 89 | ||
| 90 | public String toString() { | |
| 91 |
1
1. toString : replaced return value with "" for com/ancientprogramming/fixedformat4j/format/data/FixedFormatDecimalData::toString → SURVIVED |
return String.format("FixedFormatDecimalData{decimals=%d, useDecimalDelimiter=%b, decimalDelimiter='%c', roundingMode='%s'}", |
| 92 | decimals, useDecimalDelimiter, decimalDelimiter, roundingMode); | |
| 93 | } | |
| 94 | } | |
Mutations | ||
| 60 |
1.1 |
|
| 69 |
1.1 2.2 |
|
| 78 |
1.1 |
|
| 87 |
1.1 |
|
| 91 |
1.1 |