FieldDescriptor.java

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
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache]/[method:allSimpleFieldDescriptorsAreMarkedAsLoadFields()]
Removed assignment to member variable target → KILLED

56

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache]/[method:eachSimpleFieldDescriptorHasNonNullMetadata()]
Removed assignment to member variable setter → KILLED

57

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache]/[method:eachSimpleFieldDescriptorHasNonNullMetadata()]
Removed assignment to member variable setterHandle → KILLED

58

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache]/[method:eachSimpleFieldDescriptorHasNonNullMetadata()]
Removed assignment to member variable fieldAnnotation → KILLED

59

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache]/[method:eachSimpleFieldDescriptorHasNonNullMetadata()]
Removed assignment to member variable datatype → KILLED

60

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache]/[method:nestedRecordFieldDescriptorHasNullFormatter()]
Removed assignment to member variable context → KILLED

61

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache]/[method:nestedRecordFieldDescriptorHasNullFormatter()]
Removed assignment to member variable formatInstructions → KILLED

62

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache]/[method:fieldWithCustomFormatterIsNotMarkedAsNestedRecord()]
Removed assignment to member variable formatter → KILLED

63

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache]/[method:repeatingFieldDescriptorHasNullContextAndInstructions()]
Removed assignment to member variable isRepeating → KILLED

64

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache]/[method:nestedRecordFieldDescriptorHasNullFormatter()]
Removed assignment to member variable isNestedRecord → KILLED

65

1.1
Location : <init>
Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestClassMetadataCache]/[method:allSimpleFieldDescriptorsAreMarkedAsLoadFields()]
Removed assignment to member variable isLoadField → KILLED

Active mutators

Tests examined


Report generated by PIT 1.23.1 support