Merge pull request #29230 from izeye

* pr/29230:
  Polish ReflectionHintsPredicates

Closes gh-29230
This commit is contained in:
Stephane Nicoll 2022-09-30 15:30:49 +02:00
commit 7e7e4efb01
1 changed files with 7 additions and 7 deletions

View File

@ -109,7 +109,7 @@ public class ReflectionHintsPredicates {
*/ */
public MethodHintPredicate onMethod(Class<?> type, String methodName) { public MethodHintPredicate onMethod(Class<?> type, String methodName) {
Assert.notNull(type, "'type' should not be null"); Assert.notNull(type, "'type' should not be null");
Assert.hasText(methodName, "'methodName' should not be null"); Assert.hasText(methodName, "'methodName' should not be empty");
return new MethodHintPredicate(getMethod(type, methodName)); return new MethodHintPredicate(getMethod(type, methodName));
} }
@ -125,8 +125,8 @@ public class ReflectionHintsPredicates {
* @throws IllegalArgumentException if the method cannot be found or if multiple methods are found with the same name. * @throws IllegalArgumentException if the method cannot be found or if multiple methods are found with the same name.
*/ */
public MethodHintPredicate onMethod(String className, String methodName) throws ClassNotFoundException { public MethodHintPredicate onMethod(String className, String methodName) throws ClassNotFoundException {
Assert.notNull(className, "'className' should not be null"); Assert.hasText(className, "'className' should not be empty");
Assert.hasText(methodName, "'methodName' should not be null"); Assert.hasText(methodName, "'methodName' should not be empty");
return onMethod(Class.forName(className), methodName); return onMethod(Class.forName(className), methodName);
} }
@ -147,7 +147,7 @@ public class ReflectionHintsPredicates {
/** /**
* Return a predicate that checks whether a reflection hint is registered for the field that matches the given selector. * Return a predicate that checks whether a reflection hint is registered for the field that matches the given selector.
* This looks up a field on the given type with the expected name, if present. * This looks up a field on the given type with the expected name, if present.
* By default, unsafe or write access are not considered. * By default, unsafe or write access is not considered.
* <p>The returned type exposes additional methods that refine the predicate behavior. * <p>The returned type exposes additional methods that refine the predicate behavior.
* @param type the type holding the field * @param type the type holding the field
* @param fieldName the field name * @param fieldName the field name
@ -167,7 +167,7 @@ public class ReflectionHintsPredicates {
/** /**
* Return a predicate that checks whether a reflection hint is registered for the field that matches the given selector. * Return a predicate that checks whether a reflection hint is registered for the field that matches the given selector.
* This looks up a field on the given type with the expected name, if present. * This looks up a field on the given type with the expected name, if present.
* By default, unsafe or write access are not considered. * By default, unsafe or write access is not considered.
* <p>The returned type exposes additional methods that refine the predicate behavior. * <p>The returned type exposes additional methods that refine the predicate behavior.
* @param className the name of the class holding the field * @param className the name of the class holding the field
* @param fieldName the field name * @param fieldName the field name
@ -176,14 +176,14 @@ public class ReflectionHintsPredicates {
* @throws IllegalArgumentException if a field cannot be found with the given name. * @throws IllegalArgumentException if a field cannot be found with the given name.
*/ */
public FieldHintPredicate onField(String className, String fieldName) throws ClassNotFoundException { public FieldHintPredicate onField(String className, String fieldName) throws ClassNotFoundException {
Assert.notNull(className, "'className' should not be null"); Assert.hasText(className, "'className' should not be empty");
Assert.hasText(fieldName, "'fieldName' should not be empty"); Assert.hasText(fieldName, "'fieldName' should not be empty");
return onField(Class.forName(className), fieldName); return onField(Class.forName(className), fieldName);
} }
/** /**
* Return a predicate that checks whether a reflection hint is registered for the given field. * Return a predicate that checks whether a reflection hint is registered for the given field.
* By default, unsafe or write access are not considered. * By default, unsafe or write access is not considered.
* <p>The returned type exposes additional methods that refine the predicate behavior. * <p>The returned type exposes additional methods that refine the predicate behavior.
* @param field the field * @param field the field
* @return the {@link RuntimeHints} predicate * @return the {@link RuntimeHints} predicate