Named Record
@Target(allowedTargets = [AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.PROPERTY ] )
Specifies the field name to be used for mapping a Java Record component when parameter names are not available at runtime.
This annotation is useful for environments where the Java compiler was invoked without the -parameters option, causing constructor parameter names to be omitted from the class file.
Example:
record MyConfig(
@NamedRecord("some_field") String someValue,
@NamedRecord("another_field") int anotherValue
) {}Content copied to clipboard
When parsing YAML, the parser will look up some_field and another_field from the YAML data instead of relying on the parameter names.