| 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.impl; | |
| 17 | ||
| 18 | import com.ancientprogramming.fixedformat4j.annotation.Sign; | |
| 19 | import com.ancientprogramming.fixedformat4j.format.AbstractFixedFormatter; | |
| 20 | import com.ancientprogramming.fixedformat4j.format.FormatInstructions; | |
| 21 | ||
| 22 | /** | |
| 23 | * Apply signing to values | |
| 24 | * | |
| 25 | * @author Jacob von Eyben - <a href="https://eybenconsult.com">https://eybenconsult.com</a> | |
| 26 | * @since 1.1.0 | |
| 27 | */ | |
| 28 | public abstract class AbstractNumberFormatter<T> extends AbstractFixedFormatter<T> { | |
| 29 | ||
| 30 | /** | |
| 31 | * Override and applies signing instead of align. | |
| 32 | * | |
| 33 | * @param value the value | |
| 34 | * @param instructions the instructions | |
| 35 | * @return the parsed object | |
| 36 | */ | |
| 37 | public T parse(String value, FormatInstructions instructions) { | |
| 38 | T result = null; | |
| 39 |
3
1. parse : removed conditional - replaced equality check with true → SURVIVED 2. parse : negated conditional → KILLED 3. parse : removed conditional - replaced equality check with false → KILLED |
if (value != null) { |
| 40 |
2
1. parse : removed call to com/ancientprogramming/fixedformat4j/format/FormatInstructions::getFixedFormatNumberData → KILLED 2. parse : removed call to com/ancientprogramming/fixedformat4j/format/data/FixedFormatNumberData::getSigning → KILLED |
Sign signing = instructions.getFixedFormatNumberData().getSigning(); |
| 41 |
2
1. parse : removed call to com/ancientprogramming/fixedformat4j/annotation/Sign::remove → KILLED 2. parse : replaced call to com/ancientprogramming/fixedformat4j/annotation/Sign::remove with argument → KILLED |
String rawString = signing.remove(value, instructions); |
| 42 |
1
1. parse : removed call to com/ancientprogramming/fixedformat4j/format/impl/AbstractNumberFormatter::asObject → KILLED |
result = asObject(rawString, instructions); |
| 43 | } | |
| 44 |
1
1. parse : replaced return value with null for com/ancientprogramming/fixedformat4j/format/impl/AbstractNumberFormatter::parse → KILLED |
return result; |
| 45 | } | |
| 46 | ||
| 47 | /** | |
| 48 | * Override and applies signing instead of align. | |
| 49 | * | |
| 50 | * @param obj the object to format | |
| 51 | * @param instructions the instructions | |
| 52 | * @return the raw value | |
| 53 | */ | |
| 54 | public String format(T obj, FormatInstructions instructions) { | |
| 55 |
6
1. format : removed call to com/ancientprogramming/fixedformat4j/annotation/Sign::apply → KILLED 2. format : removed call to com/ancientprogramming/fixedformat4j/format/impl/AbstractNumberFormatter::asString → KILLED 3. format : removed call to com/ancientprogramming/fixedformat4j/format/FormatInstructions::getFixedFormatNumberData → KILLED 4. format : removed call to com/ancientprogramming/fixedformat4j/format/data/FixedFormatNumberData::getSigning → KILLED 5. format : replaced return value with "" for com/ancientprogramming/fixedformat4j/format/impl/AbstractNumberFormatter::format → KILLED 6. format : replaced call to com/ancientprogramming/fixedformat4j/annotation/Sign::apply with argument → KILLED |
return instructions.getFixedFormatNumberData().getSigning().apply(asString(obj, instructions), instructions); |
| 56 | } | |
| 57 | } | |
Mutations | ||
| 39 |
1.1 2.2 3.3 |
|
| 40 |
1.1 2.2 |
|
| 41 |
1.1 2.2 |
|
| 42 |
1.1 |
|
| 44 |
1.1 |
|
| 55 |
1.1 2.2 3.3 4.4 5.5 6.6 |