FixedFormatDecimalData.java

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 1 1. <init> : Removed assignment to member variable decimals → KILLED
    this.decimals = decimals;
49 1 1. <init> : Removed assignment to member variable useDecimalDelimiter → KILLED
    this.useDecimalDelimiter = useDecimalDelimiter;
50 1 1. <init> : Removed assignment to member variable decimalDelimiter → KILLED
    this.decimalDelimiter = decimalDelimiter;
51 1 1. <init> : Removed assignment to member variable roundingMode → KILLED
    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 true for com/ancientprogramming/fixedformat4j/format/data/FixedFormatDecimalData::isUseDecimalDelimiter → KILLED
2. isUseDecimalDelimiter : replaced boolean return with false 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 5 1. toString : Substituted 4 with 5 → SURVIVED
2. toString : replaced call to java/lang/String::format with argument → KILLED
3. toString : removed call to java/lang/String::format → KILLED
4. toString : replaced return value with "" for com/ancientprogramming/fixedformat4j/format/data/FixedFormatDecimalData::toString → KILLED
5. toString : Substituted 0 with 1 → KILLED
    return String.format("FixedFormatDecimalData{decimals=%d, useDecimalDelimiter=%b, decimalDelimiter='%c', roundingMode='%s'}",
92 6 1. toString : Substituted 2 with 3 → SURVIVED
2. toString : removed call to java/lang/Character::valueOf → SURVIVED
3. toString : Substituted 1 with 0 → KILLED
4. toString : removed call to java/lang/Integer::valueOf → KILLED
5. toString : Substituted 3 with 4 → KILLED
6. toString : removed call to java/lang/Boolean::valueOf → KILLED
        decimals, useDecimalDelimiter, decimalDelimiter, roundingMode);
93
  }
94
}

Mutations

48

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:getDecimals_returnsConstructorArg()]
Removed assignment to member variable decimals → KILLED

49

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:isUseDecimalDelimiter_trueWhenPassedTrue()]
Removed assignment to member variable useDecimalDelimiter → KILLED

50

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:getDecimalDelimiter_returnsConstructorArg()]
Removed assignment to member variable decimalDelimiter → KILLED

51

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:getRoundingMode_returnsConstructorArg()]
Removed assignment to member variable roundingMode → KILLED

60

1.1
Location : getDecimals
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:defaultInstance_hasExpectedDecimals()]
replaced int return with 0 for com/ancientprogramming/fixedformat4j/format/data/FixedFormatDecimalData::getDecimals → KILLED

69

1.1
Location : isUseDecimalDelimiter
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:isUseDecimalDelimiter_falseWhenPassedFalse()]
replaced boolean return with true for com/ancientprogramming/fixedformat4j/format/data/FixedFormatDecimalData::isUseDecimalDelimiter → KILLED

2.2
Location : isUseDecimalDelimiter
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:isUseDecimalDelimiter_trueWhenPassedTrue()]
replaced boolean return with false for com/ancientprogramming/fixedformat4j/format/data/FixedFormatDecimalData::isUseDecimalDelimiter → KILLED

78

1.1
Location : getDecimalDelimiter
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:getDecimalDelimiter_returnsConstructorArg()]
replaced char return with 0 for com/ancientprogramming/fixedformat4j/format/data/FixedFormatDecimalData::getDecimalDelimiter → KILLED

87

1.1
Location : getRoundingMode
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:getRoundingMode_returnsConstructorArg()]
replaced return value with null for com/ancientprogramming/fixedformat4j/format/data/FixedFormatDecimalData::getRoundingMode → KILLED

91

1.1
Location : toString
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:toString_containsRoundingMode()]
replaced call to java/lang/String::format with argument → KILLED

2.2
Location : toString
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:toString_containsRoundingMode()]
removed call to java/lang/String::format → KILLED

3.3
Location : toString
Killed by : none
Substituted 4 with 5 → SURVIVED
Covering tests

4.4
Location : toString
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:toString_containsRoundingMode()]
replaced return value with "" for com/ancientprogramming/fixedformat4j/format/data/FixedFormatDecimalData::toString → KILLED

5.5
Location : toString
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:toString_containsDecimalsValue()]
Substituted 0 with 1 → KILLED

92

1.1
Location : toString
Killed by : none
Substituted 2 with 3 → SURVIVED
Covering tests

2.2
Location : toString
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:toString_containsRoundingMode()]
Substituted 1 with 0 → KILLED

3.3
Location : toString
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:toString_containsDecimalsValue()]
removed call to java/lang/Integer::valueOf → KILLED

4.4
Location : toString
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:toString_containsRoundingMode()]
Substituted 3 with 4 → KILLED

5.5
Location : toString
Killed by : none
removed call to java/lang/Character::valueOf → SURVIVED Covering tests

6.6
Location : toString
Killed by : com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.data.TestFixedFormatDecimalData]/[method:toString_containsUseDecimalDelimiterValue()]
removed call to java/lang/Boolean::valueOf → KILLED

Active mutators

Tests examined


Report generated by PIT 1.23.1 support