Skip to content

Commit

Permalink
Improve @RegisterReflectionForBinding for enums
Browse files Browse the repository at this point in the history
  • Loading branch information
sdeleuze committed Dec 5, 2023
1 parent c74d60b commit 3f9a809
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ private void registerReflectionHints(ReflectionHints hints, Set<Type> seen, Type
registerRecordHints(hints, seen, recordComponent.getAccessor());
}
}
if (clazz.isEnum()) {
typeHint.withMembers(
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
MemberCategory.INVOKE_PUBLIC_METHODS);
}
typeHint.withMembers(
MemberCategory.DECLARED_FIELDS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ void registerTypeForSerializationWithMultipleLevelsAndCollection() {
@Test
void registerTypeForSerializationWithEnum() {
bindingRegistrar.registerReflectionHints(this.hints.reflection(), SampleEnum.class);
assertThat(this.hints.reflection().typeHints()).singleElement()
.satisfies(typeHint -> assertThat(typeHint.getType()).isEqualTo(TypeReference.of(SampleEnum.class)));
assertThat(RuntimeHintsPredicates.reflection().onType(SampleEnum.class).withMemberCategories(
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS)).accepts(this.hints);
}

@Test
Expand Down

0 comments on commit 3f9a809

Please sign in to comment.