| 1 | package com.ancientprogramming.fixedformat4j.format.impl; | |
| 2 | ||
| 3 | import com.ancientprogramming.fixedformat4j.annotation.Field; | |
| 4 | import com.ancientprogramming.fixedformat4j.format.FixedFormatter; | |
| 5 | import com.ancientprogramming.fixedformat4j.format.FormatContext; | |
| 6 | import com.ancientprogramming.fixedformat4j.format.FormatInstructions; | |
| 7 | ||
| 8 | import java.lang.invoke.MethodHandle; | |
| 9 | import java.lang.reflect.Method; | |
| 10 | ||
| 11 | /** | |
| 12 | * Immutable bundle of all per-field metadata computed once per class and cached for reuse across | |
| 13 | * every {@code load()} and {@code export()} call. | |
| 14 | * | |
| 15 | * <p>For repeating fields ({@code count > 1}), {@link #context}, {@link #formatInstructions}, and | |
| 16 | * {@link #formatter} are {@code null} — the runtime delegates to {@link RepeatingFieldSupport}. | |
| 17 | * For fields whose type is itself a {@code @Record}, {@link #formatter} is {@code null} and the | |
| 18 | * runtime recurses into {@code FixedFormatManagerImpl}. | |
| 19 | * | |
| 20 | * @author Jacob von Eyben - <a href="https://eybenconsult.com">https://eybenconsult.com</a> | |
| 21 | * @since 1.7.0 | |
| 22 | */ | |
| 23 | class FieldDescriptor { | |
| 24 | ||
| 25 | final AnnotationTarget target; | |
| 26 | final Method setter; | |
| 27 | final MethodHandle setterHandle; | |
| 28 | final Field fieldAnnotation; | |
| 29 | final Class<?> datatype; | |
| 30 | final FormatContext<?> context; | |
| 31 | final FormatInstructions formatInstructions; | |
| 32 | final FixedFormatter<?> formatter; | |
| 33 | final boolean isRepeating; | |
| 34 | final boolean isNestedRecord; | |
| 35 | /** | |
| 36 | * {@code true} when this descriptor should participate in {@code load()} (i.e. its parsed value | |
| 37 | * is written to the POJO via the setter). For plain {@code @Field} annotations this is always | |
| 38 | * {@code true}. For {@code @Fields}, only the first annotation in the array is a load field; | |
| 39 | * the remainder are export-only. | |
| 40 | */ | |
| 41 | final boolean isLoadField; | |
| 42 | ||
| 43 | FieldDescriptor( | |
| 44 | AnnotationTarget target, | |
| 45 | Method setter, | |
| 46 | MethodHandle setterHandle, | |
| 47 | Field fieldAnnotation, | |
| 48 | Class<?> datatype, | |
| 49 | FormatContext<?> context, | |
| 50 | FormatInstructions formatInstructions, | |
| 51 | FixedFormatter<?> formatter, | |
| 52 | boolean isRepeating, | |
| 53 | boolean isNestedRecord, | |
| 54 | boolean isLoadField) { | |
| 55 |
1
1. <init> : Removed assignment to member variable target → KILLED |
this.target = target; |
| 56 |
1
1. <init> : Removed assignment to member variable setter → KILLED |
this.setter = setter; |
| 57 |
1
1. <init> : Removed assignment to member variable setterHandle → KILLED |
this.setterHandle = setterHandle; |
| 58 |
1
1. <init> : Removed assignment to member variable fieldAnnotation → KILLED |
this.fieldAnnotation = fieldAnnotation; |
| 59 |
1
1. <init> : Removed assignment to member variable datatype → KILLED |
this.datatype = datatype; |
| 60 |
1
1. <init> : Removed assignment to member variable context → KILLED |
this.context = context; |
| 61 |
1
1. <init> : Removed assignment to member variable formatInstructions → KILLED |
this.formatInstructions = formatInstructions; |
| 62 |
1
1. <init> : Removed assignment to member variable formatter → KILLED |
this.formatter = formatter; |
| 63 |
1
1. <init> : Removed assignment to member variable isRepeating → KILLED |
this.isRepeating = isRepeating; |
| 64 |
1
1. <init> : Removed assignment to member variable isNestedRecord → KILLED |
this.isNestedRecord = isNestedRecord; |
| 65 |
1
1. <init> : Removed assignment to member variable isLoadField → KILLED |
this.isLoadField = isLoadField; |
| 66 | } | |
| 67 | } | |
Mutations | ||
| 55 |
1.1 |
|
| 56 |
1.1 |
|
| 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 |