| 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 |
1
1. parse : negated conditional → KILLED |
if (value != null) { |
| 40 | Sign signing = instructions.getFixedFormatNumberData().getSigning(); | |
| 41 | String rawString = signing.remove(value, instructions); | |
| 42 | 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 |
1
1. format : replaced return value with "" for com/ancientprogramming/fixedformat4j/format/impl/AbstractNumberFormatter::format → KILLED |
return instructions.getFixedFormatNumberData().getSigning().apply(asString(obj, instructions), instructions); |
| 56 | } | |
| 57 | } | |
Mutations | ||
| 39 |
1.1 |
|
| 44 |
1.1 |
|
| 55 |
1.1 |