@@ -114,6 +114,23 @@ public MethodHintPredicate onMethod(Class<?> type, String methodName) {
114
114
return new MethodHintPredicate (getMethod (type , methodName ));
115
115
}
116
116
117
+ /**
118
+ * Return a predicate that checks whether a reflection hint is registered for the method that matches the given selector.
119
+ * This looks up a method on the given type with the expected name, if unique.
120
+ * By default, both introspection and invocation hints match.
121
+ * <p>The returned type exposes additional methods that refine the predicate behavior.
122
+ * @param className the name of the class holding the method
123
+ * @param methodName the method name
124
+ * @return the {@link RuntimeHints} predicate
125
+ * @throws ClassNotFoundException if the class cannot be resolved.
126
+ * @throws IllegalArgumentException if the method cannot be found or if multiple methods are found with the same name.
127
+ */
128
+ public MethodHintPredicate onMethod (String className , String methodName ) throws ClassNotFoundException {
129
+ Assert .notNull (className , "'className' should not be null" );
130
+ Assert .hasText (methodName , "'methodName' should not be null" );
131
+ return onMethod (Class .forName (className ), methodName );
132
+ }
133
+
117
134
private Method getMethod (Class <?> type , String methodName ) {
118
135
ReflectionUtils .MethodFilter selector = method -> methodName .equals (method .getName ());
119
136
Set <Method > methods = MethodIntrospector .selectMethods (type , selector );
@@ -148,6 +165,23 @@ public FieldHintPredicate onField(Class<?> type, String fieldName) {
148
165
return new FieldHintPredicate (field );
149
166
}
150
167
168
+ /**
169
+ * Return a predicate that checks whether a reflection hint is registered for the field that matches the given selector.
170
+ * This looks up a field on the given type with the expected name, if present.
171
+ * By default, unsafe or write access are not considered.
172
+ * <p>The returned type exposes additional methods that refine the predicate behavior.
173
+ * @param className the name of the class holding the field
174
+ * @param fieldName the field name
175
+ * @return the {@link RuntimeHints} predicate
176
+ * @throws ClassNotFoundException if the class cannot be resolved.
177
+ * @throws IllegalArgumentException if a field cannot be found with the given name.
178
+ */
179
+ public FieldHintPredicate onField (String className , String fieldName ) throws ClassNotFoundException {
180
+ Assert .notNull (className , "'className' should not be null" );
181
+ Assert .hasText (fieldName , "'fieldName' should not be empty" );
182
+ return onField (Class .forName (className ), fieldName );
183
+ }
184
+
151
185
/**
152
186
* Return a predicate that checks whether a reflection hint is registered for the given field.
153
187
* By default, unsafe or write access are not considered.
0 commit comments