I made a record that i want to use as dto object like this:
@Introspected()
@Requires(beans=MyEnum.class)//that was just a try
public record MyDtoRecord(String id, MyEnum enumField) {
}
and a Enum like this:
@Introspected()
public enum MyEnum {
AVALUE("aText"),
BVALUE("bText");
public String text;
MyEnum(String text) {
this.text = text;
}
}
I would expected to recieve my dto with the enum as property with the enum fields. Like this:
{id:"hello",enumField:{AVALUE:{text:"atext"}}}
//or like this:
{id:"hello",enumField:{value:"AVALUE", text:"atext"}}
but instead i only get the enum identifier:
{id:"hello",enumField:"AVALUE"}
I already tried to use custom annotations on fields of the enum with the includedAnnotations - Parameter of @Introspected I also tried accessKind METHODE.
Nothing changed.
Is it not possible to get the fields of an enum field in a introspected class?
You can annotate the text
field with @com.fasterxml.jackson.annotation.JsonValue
.