| 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; | |
| 17 | ||
| 18 | import com.ancientprogramming.fixedformat4j.annotation.Align; | |
| 19 | import com.ancientprogramming.fixedformat4j.annotation.Field; | |
| 20 | ||
| 21 | /** | |
| 22 | * Immutable description of one {@code @Field} of a record class, as returned by | |
| 23 | * {@link FixedFormatIntrospector#introspect(Class)}. | |
| 24 | * | |
| 25 | * <p>All values are fully resolved: {@link #getEffectiveAlignment()} is never | |
| 26 | * {@link Align#INHERIT} — record-level alignment defaults have already been applied. | |
| 27 | * | |
| 28 | * @author Jacob von Eyben - <a href="https://eybenconsult.com">https://eybenconsult.com</a> | |
| 29 | * @since 1.9.0 | |
| 30 | */ | |
| 31 | public final class FieldInfo { | |
| 32 | ||
| 33 | private final String propertyName; | |
| 34 | private final int offset; | |
| 35 | private final int length; | |
| 36 | private final Class<?> dataType; | |
| 37 | private final Align effectiveAlignment; | |
| 38 | private final char paddingChar; | |
| 39 | private final char nullChar; | |
| 40 | private final String nullValue; | |
| 41 | private final Class<? extends FixedFormatter<?>> formatterClass; | |
| 42 | private final int repeatCount; | |
| 43 | private final boolean nestedRecord; | |
| 44 | ||
| 45 | public FieldInfo( | |
| 46 | String propertyName, | |
| 47 | int offset, | |
| 48 | int length, | |
| 49 | Class<?> dataType, | |
| 50 | Align effectiveAlignment, | |
| 51 | char paddingChar, | |
| 52 | char nullChar, | |
| 53 | String nullValue, | |
| 54 | Class<? extends FixedFormatter<?>> formatterClass, | |
| 55 | int repeatCount, | |
| 56 | boolean nestedRecord) { | |
| 57 |
1
1. <init> : Removed assignment to member variable propertyName → KILLED |
this.propertyName = propertyName; |
| 58 |
1
1. <init> : Removed assignment to member variable offset → KILLED |
this.offset = offset; |
| 59 |
1
1. <init> : Removed assignment to member variable length → KILLED |
this.length = length; |
| 60 |
1
1. <init> : Removed assignment to member variable dataType → KILLED |
this.dataType = dataType; |
| 61 |
1
1. <init> : Removed assignment to member variable effectiveAlignment → KILLED |
this.effectiveAlignment = effectiveAlignment; |
| 62 |
1
1. <init> : Removed assignment to member variable paddingChar → KILLED |
this.paddingChar = paddingChar; |
| 63 |
1
1. <init> : Removed assignment to member variable nullChar → KILLED |
this.nullChar = nullChar; |
| 64 |
1
1. <init> : Removed assignment to member variable nullValue → KILLED |
this.nullValue = nullValue; |
| 65 |
1
1. <init> : Removed assignment to member variable formatterClass → KILLED |
this.formatterClass = formatterClass; |
| 66 |
1
1. <init> : Removed assignment to member variable repeatCount → KILLED |
this.repeatCount = repeatCount; |
| 67 |
1
1. <init> : Removed assignment to member variable nestedRecord → KILLED |
this.nestedRecord = nestedRecord; |
| 68 | } | |
| 69 | ||
| 70 | /** | |
| 71 | * @return the bean-style property name, e.g. {@code "customerId"} for {@code getCustomerId()}; | |
| 72 | * for Java record classes the component name as-is | |
| 73 | */ | |
| 74 | public String getPropertyName() { | |
| 75 |
1
1. getPropertyName : replaced return value with "" for com/ancientprogramming/fixedformat4j/format/FieldInfo::getPropertyName → KILLED |
return propertyName; |
| 76 | } | |
| 77 | ||
| 78 | /** @return the 1-based offset of the field within the record */ | |
| 79 | public int getOffset() { | |
| 80 |
1
1. getOffset : replaced int return with 0 for com/ancientprogramming/fixedformat4j/format/FieldInfo::getOffset → KILLED |
return offset; |
| 81 | } | |
| 82 | ||
| 83 | /** @return the field length in characters, or {@link Field#REST_OF_LINE} ({@code -1}) */ | |
| 84 | public int getLength() { | |
| 85 |
1
1. getLength : replaced int return with 0 for com/ancientprogramming/fixedformat4j/format/FieldInfo::getLength → KILLED |
return length; |
| 86 | } | |
| 87 | ||
| 88 | /** @return the declared Java type of the property (the collection/array type for repeating fields) */ | |
| 89 | public Class<?> getDataType() { | |
| 90 |
1
1. getDataType : replaced return value with null for com/ancientprogramming/fixedformat4j/format/FieldInfo::getDataType → KILLED |
return dataType; |
| 91 | } | |
| 92 | ||
| 93 | /** @return the resolved alignment — {@link Align#LEFT} or {@link Align#RIGHT}, never {@link Align#INHERIT} */ | |
| 94 | public Align getEffectiveAlignment() { | |
| 95 |
1
1. getEffectiveAlignment : replaced return value with null for com/ancientprogramming/fixedformat4j/format/FieldInfo::getEffectiveAlignment → KILLED |
return effectiveAlignment; |
| 96 | } | |
| 97 | ||
| 98 | /** @return the padding character */ | |
| 99 | public char getPaddingChar() { | |
| 100 |
1
1. getPaddingChar : replaced char return with 0 for com/ancientprogramming/fixedformat4j/format/FieldInfo::getPaddingChar → KILLED |
return paddingChar; |
| 101 | } | |
| 102 | ||
| 103 | /** @return the null sentinel character, or {@link Field#UNSET_NULL_CHAR} when not configured */ | |
| 104 | public char getNullChar() { | |
| 105 |
1
1. getNullChar : replaced char return with 0 for com/ancientprogramming/fixedformat4j/format/FieldInfo::getNullChar → KILLED |
return nullChar; |
| 106 | } | |
| 107 | ||
| 108 | /** @return the literal null sentinel string, or the empty string when not configured */ | |
| 109 | public String getNullValue() { | |
| 110 |
1
1. getNullValue : replaced return value with "" for com/ancientprogramming/fixedformat4j/format/FieldInfo::getNullValue → KILLED |
return nullValue; |
| 111 | } | |
| 112 | ||
| 113 | /** @return the configured formatter class ({@code ByTypeFormatter} when not overridden) */ | |
| 114 | public Class<? extends FixedFormatter<?>> getFormatterClass() { | |
| 115 |
1
1. getFormatterClass : replaced return value with null for com/ancientprogramming/fixedformat4j/format/FieldInfo::getFormatterClass → KILLED |
return formatterClass; |
| 116 | } | |
| 117 | ||
| 118 | /** @return the repetition count; {@code 1} for non-repeating fields */ | |
| 119 | public int getRepeatCount() { | |
| 120 |
1
1. getRepeatCount : replaced int return with 0 for com/ancientprogramming/fixedformat4j/format/FieldInfo::getRepeatCount → KILLED |
return repeatCount; |
| 121 | } | |
| 122 | ||
| 123 | /** @return {@code true} when the field's type is itself a {@code @Record} class loaded recursively */ | |
| 124 | public boolean isNestedRecord() { | |
| 125 |
2
1. isNestedRecord : replaced boolean return with true for com/ancientprogramming/fixedformat4j/format/FieldInfo::isNestedRecord → KILLED 2. isNestedRecord : replaced boolean return with false for com/ancientprogramming/fixedformat4j/format/FieldInfo::isNestedRecord → KILLED |
return nestedRecord; |
| 126 | } | |
| 127 | ||
| 128 | @Override | |
| 129 | public String toString() { | |
| 130 |
1
1. toString : replaced return value with "" for com/ancientprogramming/fixedformat4j/format/FieldInfo::toString → NO_COVERAGE |
return "FieldInfo{" + propertyName + " offset=" + offset + " length=" + length |
| 131 |
1
1. toString : removed call to java/lang/Class::getName → NO_COVERAGE |
+ " type=" + dataType.getName() + "}"; |
| 132 | } | |
| 133 | } | |
Mutations | ||
| 57 |
1.1 |
|
| 58 |
1.1 |
|
| 59 |
1.1 |
|
| 60 |
1.1 |
|
| 61 |
1.1 |
|
| 62 |
1.1 |
|
| 63 |
1.1 |
|
| 64 |
1.1 |
|
| 65 |
1.1 |
|
| 66 |
1.1 |
|
| 67 |
1.1 |
|
| 75 |
1.1 |
|
| 80 |
1.1 |
|
| 85 |
1.1 |
|
| 90 |
1.1 |
|
| 95 |
1.1 |
|
| 100 |
1.1 |
|
| 105 |
1.1 |
|
| 110 |
1.1 |
|
| 115 |
1.1 |
|
| 120 |
1.1 |
|
| 125 |
1.1 2.2 |
|
| 130 |
1.1 |
|
| 131 |
1.1 |