Polish RuntimeHintsPredicates

This commit adds a method variant checking that all `MemberCategory` are
supported by the `RuntimeHints` for a given type hint.

See gh-28555
This commit is contained in:
Brian Clozel
2022-06-13 18:27:45 +02:00
parent dc3ec5b665
commit 15b69a3ede
2 changed files with 25 additions and 0 deletions

View File

@@ -180,6 +180,16 @@ public class ReflectionHintsPredicates {
return this.and(hints -> getTypeHint(hints).getMemberCategories().contains(memberCategory));
}
/**
* Refine the current predicate to only match if the given {@link MemberCategory categories} are present.
* @param memberCategories the member categories
* @return the refined {@link RuntimeHints} predicate
*/
public Predicate<RuntimeHints> withMemberCategories(MemberCategory... memberCategories) {
Assert.notEmpty(memberCategories, "'memberCategories' should not be empty");
return this.and(hints -> getTypeHint(hints).getMemberCategories().containsAll(Arrays.asList(memberCategories)));
}
/**
* Refine the current predicate to match if any of the given {@link MemberCategory categories} is present.
* @param memberCategories the member categories