|
|
|
@ -47,6 +47,30 @@ import org.springframework.lang.Nullable; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public abstract class ReflectionUtils { |
|
|
|
public abstract class ReflectionUtils { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Pre-built MethodFilter that matches all non-bridge methods. |
|
|
|
|
|
|
|
* @since 3.0 |
|
|
|
|
|
|
|
* @deprecated as of 5.0.11, in favor of a custom {@link MethodFilter} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public static final MethodFilter NON_BRIDGED_METHODS = |
|
|
|
|
|
|
|
(method -> !method.isBridge()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Pre-built MethodFilter that matches all non-bridge non-synthetic methods |
|
|
|
|
|
|
|
* which are not declared on {@code java.lang.Object}. |
|
|
|
|
|
|
|
* @since 3.0.5 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static final MethodFilter USER_DECLARED_METHODS = |
|
|
|
|
|
|
|
(method -> (!method.isBridge() && !method.isSynthetic() && method.getDeclaringClass() != Object.class)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Pre-built FieldFilter that matches all non-static, non-final fields. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static final FieldFilter COPYABLE_FIELDS = |
|
|
|
|
|
|
|
field -> !(Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Naming prefix for CGLIB-renamed methods. |
|
|
|
* Naming prefix for CGLIB-renamed methods. |
|
|
|
* @see #isCglibRenamedMethod |
|
|
|
* @see #isCglibRenamedMethod |
|
|
|
@ -236,7 +260,9 @@ public abstract class ReflectionUtils { |
|
|
|
* @return the invocation result, if any |
|
|
|
* @return the invocation result, if any |
|
|
|
* @throws SQLException the JDBC API SQLException to rethrow (if any) |
|
|
|
* @throws SQLException the JDBC API SQLException to rethrow (if any) |
|
|
|
* @see #invokeJdbcMethod(java.lang.reflect.Method, Object, Object[]) |
|
|
|
* @see #invokeJdbcMethod(java.lang.reflect.Method, Object, Object[]) |
|
|
|
|
|
|
|
* @deprecated as of 5.0.11, in favor of custom SQLException handling |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
public static Object invokeJdbcMethod(Method method, @Nullable Object target) throws SQLException { |
|
|
|
public static Object invokeJdbcMethod(Method method, @Nullable Object target) throws SQLException { |
|
|
|
return invokeJdbcMethod(method, target, new Object[0]); |
|
|
|
return invokeJdbcMethod(method, target, new Object[0]); |
|
|
|
@ -251,7 +277,9 @@ public abstract class ReflectionUtils { |
|
|
|
* @return the invocation result, if any |
|
|
|
* @return the invocation result, if any |
|
|
|
* @throws SQLException the JDBC API SQLException to rethrow (if any) |
|
|
|
* @throws SQLException the JDBC API SQLException to rethrow (if any) |
|
|
|
* @see #invokeMethod(java.lang.reflect.Method, Object, Object[]) |
|
|
|
* @see #invokeMethod(java.lang.reflect.Method, Object, Object[]) |
|
|
|
|
|
|
|
* @deprecated as of 5.0.11, in favor of custom SQLException handling |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
public static Object invokeJdbcMethod(Method method, @Nullable Object target, @Nullable Object... args) |
|
|
|
public static Object invokeJdbcMethod(Method method, @Nullable Object target, @Nullable Object... args) |
|
|
|
throws SQLException { |
|
|
|
throws SQLException { |
|
|
|
@ -511,8 +539,8 @@ public abstract class ReflectionUtils { |
|
|
|
* on Java 8 based interfaces that the given class implements). |
|
|
|
* on Java 8 based interfaces that the given class implements). |
|
|
|
* @param clazz the class to introspect |
|
|
|
* @param clazz the class to introspect |
|
|
|
* @param mc the callback to invoke for each method |
|
|
|
* @param mc the callback to invoke for each method |
|
|
|
* @since 4.2 |
|
|
|
|
|
|
|
* @throws IllegalStateException if introspection fails |
|
|
|
* @throws IllegalStateException if introspection fails |
|
|
|
|
|
|
|
* @since 4.2 |
|
|
|
* @see #doWithMethods |
|
|
|
* @see #doWithMethods |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static void doWithLocalMethods(Class<?> clazz, MethodCallback mc) { |
|
|
|
public static void doWithLocalMethods(Class<?> clazz, MethodCallback mc) { |
|
|
|
@ -682,8 +710,8 @@ public abstract class ReflectionUtils { |
|
|
|
* Invoke the given callback on all locally declared fields in the given class. |
|
|
|
* Invoke the given callback on all locally declared fields in the given class. |
|
|
|
* @param clazz the target class to analyze |
|
|
|
* @param clazz the target class to analyze |
|
|
|
* @param fc the callback to invoke for each field |
|
|
|
* @param fc the callback to invoke for each field |
|
|
|
* @since 4.2 |
|
|
|
|
|
|
|
* @throws IllegalStateException if introspection fails |
|
|
|
* @throws IllegalStateException if introspection fails |
|
|
|
|
|
|
|
* @since 4.2 |
|
|
|
* @see #doWithFields |
|
|
|
* @see #doWithFields |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static void doWithLocalFields(Class<?> clazz, FieldCallback fc) { |
|
|
|
public static void doWithLocalFields(Class<?> clazz, FieldCallback fc) { |
|
|
|
@ -846,26 +874,4 @@ public abstract class ReflectionUtils { |
|
|
|
boolean matches(Field field); |
|
|
|
boolean matches(Field field); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Pre-built FieldFilter that matches all non-static, non-final fields. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static final FieldFilter COPYABLE_FIELDS = |
|
|
|
|
|
|
|
field -> !(Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Pre-built MethodFilter that matches all non-bridge methods. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static final MethodFilter NON_BRIDGED_METHODS = |
|
|
|
|
|
|
|
(method -> !method.isBridge()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Pre-built MethodFilter that matches all non-bridge non-synthetic methods |
|
|
|
|
|
|
|
* which are not declared on {@code java.lang.Object}. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static final MethodFilter USER_DECLARED_METHODS = |
|
|
|
|
|
|
|
(method -> (!method.isBridge() && !method.isSynthetic() && method.getDeclaringClass() != Object.class)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|