File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
main/java/org/springframework/aot/hint
test/java/org/springframework/aot/hint Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,16 @@ public Predicate<RuntimeHints> withMemberCategory(MemberCategory memberCategory)
180
180
return this .and (hints -> getTypeHint (hints ).getMemberCategories ().contains (memberCategory ));
181
181
}
182
182
183
+ /**
184
+ * Refine the current predicate to only match if the given {@link MemberCategory categories} are present.
185
+ * @param memberCategories the member categories
186
+ * @return the refined {@link RuntimeHints} predicate
187
+ */
188
+ public Predicate <RuntimeHints > withMemberCategories (MemberCategory ... memberCategories ) {
189
+ Assert .notEmpty (memberCategories , "'memberCategories' should not be empty" );
190
+ return this .and (hints -> getTypeHint (hints ).getMemberCategories ().containsAll (Arrays .asList (memberCategories )));
191
+ }
192
+
183
193
/**
184
194
* Refine the current predicate to match if any of the given {@link MemberCategory categories} is present.
185
195
* @param memberCategories the member categories
Original file line number Diff line number Diff line change @@ -98,6 +98,21 @@ void typeWithMemberCategoryDoesNotMatchOtherCategory() {
98
98
assertPredicateDoesNotMatch (reflection .onType (SampleClass .class ).withMemberCategory (MemberCategory .INVOKE_PUBLIC_METHODS ));
99
99
}
100
100
101
+ @ Test
102
+ void typeWithMemberCategoriesMatchesCategories () {
103
+ runtimeHints .reflection ().registerType (SampleClass .class , builder ->
104
+ builder .withMembers (MemberCategory .INTROSPECT_PUBLIC_CONSTRUCTORS , MemberCategory .INTROSPECT_PUBLIC_METHODS ));
105
+ assertPredicateMatches (reflection .onType (SampleClass .class )
106
+ .withMemberCategories (MemberCategory .INTROSPECT_PUBLIC_CONSTRUCTORS , MemberCategory .INTROSPECT_PUBLIC_METHODS ));
107
+ }
108
+
109
+ @ Test
110
+ void typeWithMemberCategoriesDoesNotMatchMissingCategory () {
111
+ runtimeHints .reflection ().registerType (SampleClass .class , builder -> builder .withMembers (MemberCategory .INTROSPECT_PUBLIC_METHODS ));
112
+ assertPredicateDoesNotMatch (reflection .onType (SampleClass .class )
113
+ .withMemberCategories (MemberCategory .INTROSPECT_PUBLIC_CONSTRUCTORS , MemberCategory .INTROSPECT_PUBLIC_METHODS ));
114
+ }
115
+
101
116
@ Test
102
117
void typeWithAnyMemberCategoryFailsWithNullCategories () {
103
118
runtimeHints .reflection ().registerType (SampleClass .class , builder -> builder .withMembers (MemberCategory .INTROSPECT_PUBLIC_METHODS ));
You can’t perform that action at this time.
0 commit comments