|
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.format.AbstractFixedFormatter; |
|
19
|
|
import com.ancientprogramming.fixedformat4j.format.FormatInstructions; |
|
20
|
|
import org.slf4j.Logger; |
|
21
|
|
import org.slf4j.LoggerFactory; |
|
22
|
|
import org.apache.commons.lang3.StringUtils; |
|
23
|
|
|
|
24
|
|
/** |
|
25
|
|
* Formatter for {@link Character} data |
|
26
|
|
* |
|
27
|
|
* @author Jacob von Eyben - <a href="https://eybenconsult.com">https://eybenconsult.com</a> |
|
28
|
|
* @since 1.0.0 |
|
29
|
|
*/ |
|
30
|
|
public class CharacterFormatter extends AbstractFixedFormatter<Character> { |
|
31
|
|
|
|
32
|
|
private static final Logger LOG = LoggerFactory.getLogger(CharacterFormatter.class); |
|
33
|
|
|
|
34
|
|
/** {@inheritDoc} */ |
|
35
|
|
public Character asObject(String string, FormatInstructions instructions) { |
|
36
|
|
Character result = null; |
|
37
|
4
1. asObject : removed call to org/apache/commons/lang3/StringUtils::isEmpty → KILLED
2. asObject : removed conditional - replaced equality check with true → KILLED
3. asObject : removed conditional - replaced equality check with false → KILLED
4. asObject : negated conditional → KILLED
|
if (!StringUtils.isEmpty(string)) { |
|
38
|
3
1. asObject : removed call to java/lang/Character::valueOf → KILLED
2. asObject : removed call to java/lang/String::charAt → KILLED
3. asObject : Substituted 0 with 1 → KILLED
|
result = string.charAt(0); |
|
39
|
6
1. asObject : removed conditional - replaced comparison check with false → KILLED
2. asObject : removed conditional - replaced comparison check with true → KILLED
3. asObject : negated conditional → KILLED
4. asObject : Substituted 1 with 0 → KILLED
5. asObject : changed conditional boundary → KILLED
6. asObject : removed call to java/lang/String::length → KILLED
|
if (string.length() > 1) { |
|
40
|
|
LOG.warn("found more than one character[{}] after reading instructions from record. Will return first character[{}]", string, result); |
|
41
|
|
} |
|
42
|
|
} |
|
43
|
1
1. asObject : replaced Character return value with 0 for com/ancientprogramming/fixedformat4j/format/impl/CharacterFormatter::asObject → KILLED
|
return result; |
|
44
|
|
} |
|
45
|
|
|
|
46
|
|
/** {@inheritDoc} */ |
|
47
|
|
public String asString(Character obj, FormatInstructions instructions) { |
|
48
|
|
String result = ""; |
|
49
|
3
1. asString : negated conditional → KILLED
2. asString : removed conditional - replaced equality check with true → KILLED
3. asString : removed conditional - replaced equality check with false → KILLED
|
if (obj != null) { |
|
50
|
2
1. asString : removed call to java/lang/Character::toString → KILLED
2. asString : removed call to java/lang/Character::charValue → KILLED
|
result = Character.toString(obj); |
|
51
|
|
} |
|
52
|
1
1. asString : replaced return value with "" for com/ancientprogramming/fixedformat4j/format/impl/CharacterFormatter::asString → KILLED
|
return result; |
|
53
|
|
} |
|
54
|
|
} |
| | Mutations |
| 37 |
|
1.1 Location : asObject Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:testParse()] removed call to org/apache/commons/lang3/StringUtils::isEmpty → KILLED
2.2 Location : asObject Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:testParse()] removed conditional - replaced equality check with true → KILLED
3.3 Location : asObject Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:testOnlyFirstCharUsedFromLongerString()] removed conditional - replaced equality check with false → KILLED
4.4 Location : asObject Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:testOnlyFirstCharUsedFromLongerString()] negated conditional → KILLED
|
| 38 |
|
1.1 Location : asObject Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:testOnlyFirstCharUsedFromLongerString()] removed call to java/lang/Character::valueOf → KILLED
2.2 Location : asObject Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:testOnlyFirstCharUsedFromLongerString()] removed call to java/lang/String::charAt → KILLED
3.3 Location : asObject Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:testOnlyFirstCharUsedFromLongerString()] Substituted 0 with 1 → KILLED
|
| 39 |
|
1.1 Location : asObject Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:parseMultiCharInput_logsWarningWithOriginalStringAndTruncatedChar()] removed conditional - replaced comparison check with false → KILLED
2.2 Location : asObject Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:parseSingleCharInput_doesNotLogWarning()] removed conditional - replaced comparison check with true → KILLED
3.3 Location : asObject Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:parseSingleCharInput_doesNotLogWarning()] negated conditional → KILLED
4.4 Location : asObject Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:parseSingleCharInput_doesNotLogWarning()] Substituted 1 with 0 → KILLED
5.5 Location : asObject Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:parseSingleCharInput_doesNotLogWarning()] changed conditional boundary → KILLED
6.6 Location : asObject Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:parseMultiCharInput_logsWarningWithOriginalStringAndTruncatedChar()] removed call to java/lang/String::length → KILLED
|
| 43 |
|
1.1 Location : asObject Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:testOnlyFirstCharUsedFromLongerString()] replaced Character return value with 0 for com/ancientprogramming/fixedformat4j/format/impl/CharacterFormatter::asObject → KILLED
|
| 49 |
|
1.1 Location : asString Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:testFormat()] negated conditional → KILLED
2.2 Location : asString Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:testFormat()] removed conditional - replaced equality check with true → KILLED
3.3 Location : asString Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:testFormat()] removed conditional - replaced equality check with false → KILLED
|
| 50 |
|
1.1 Location : asString Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:testFormat()] removed call to java/lang/Character::toString → KILLED
2.2 Location : asString Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:testFormat()] removed call to java/lang/Character::charValue → KILLED
|
| 52 |
|
1.1 Location : asString Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestCharacterFormatter]/[method:testFormat()] replaced return value with "" for com/ancientprogramming/fixedformat4j/format/impl/CharacterFormatter::asString → KILLED
|