public abstract class ClassUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
assertReturnTypeAssignable(Method method,
Class<?>... types)
Asserts the given
Method 's return type to be one of the given types. |
static int |
getNumberOfOccurences(Method method,
Class<?> type)
Deprecated.
|
static int |
getNumberOfOccurrences(Method method,
Class<?> parameterType)
Returns the number of occurrences for the given
parameter type
in the given Method . |
static boolean |
hasParameterOfType(Method method,
Class<?> type)
Returns whether the given
Method has a parameter of the given type. |
static boolean |
hasProperty(Class<?> type,
String property)
Returns whether the given class contains a property with the given name.
|
static void |
ifPresent(String className,
ClassLoader classLoader,
Consumer<Class<?>> action)
|
static boolean |
isGenericRepositoryInterface(Class<?> interfaze)
Returns wthere the given type is the
Repository interface. |
static boolean |
isGenericRepositoryInterface(String interfaceName)
Returns whether the given type name is a repository interface name.
|
static boolean |
isOfType(Object object,
Collection<Class<?>> types)
Returns whether the given object is of one of the given types.
|
static void |
unwrapReflectionException(Exception ex)
Helper method to extract the original exception that can possibly occur during a reflection call.
|
public static boolean hasProperty(Class<?> type, String property)
type
- property
- public static void ifPresent(String className, @Nullable ClassLoader classLoader, Consumer<Class<?>> action)
Class
identified by the supplied className
is present * and can be loaded and
call the action
if the Class
could be loaded.className
- the name of the class to check.classLoader
- the class loader to use.action
- the action callback to notify. (may be null
which indicates the default class loader)IllegalStateException
- if the corresponding class is resolvable but there was a readability mismatch in the
inheritance hierarchy of the class (typically a missing dependency declaration in a Jigsaw module
definition for a superclass or interface implemented by the class to be checked here)public static boolean isGenericRepositoryInterface(Class<?> interfaze)
Repository
interface.interfaze
- public static boolean isGenericRepositoryInterface(@Nullable String interfaceName)
interfaceName
- @Deprecated public static int getNumberOfOccurences(@NonNull Method method, @NonNull Class<?> type)
getNumberOfOccurrences(Method, Class)
.public static int getNumberOfOccurrences(@NonNull Method method, @NonNull Class<?> parameterType)
parameter type
in the given Method
.method
- Method
to evaluate.parameterType
- Class
of the Method
parameter type to count.parameter type
in the given Method
.Method.getParameterTypes()
public static void assertReturnTypeAssignable(Method method, Class<?>... types)
Method
's return type to be one of the given types. Will unwrap known wrapper types before
the assignment check (see QueryExecutionConverters
).method
- must not be null.types
- must not be null or empty.public static boolean isOfType(@Nullable Object object, Collection<Class<?>> types)
object
- types
- public static boolean hasParameterOfType(Method method, Class<?> type)
Method
has a parameter of the given type.method
- type
- Copyright © 2011–2023 Pivotal Software, Inc.. All rights reserved.