Modifier and Type | Class and Description |
---|---|
static class |
ExtractionUtils.AssigningConstructor
Result of the extraction in
extractAssigningConstructor(Class, List) . |
Modifier and Type | Method and Description |
---|---|
static Class<?> |
classForName(String name,
boolean initialize,
ClassLoader classLoader)
Similar to
Class.forName(String, boolean, ClassLoader) but resolves primitive names
as well. |
static List<Method> |
collectMethods(Class<?> function,
String methodName)
Collects methods of the given name.
|
static String |
createMethodSignatureString(String methodName,
Class<?>[] parameters,
Class<?> returnType)
Creates a method signature string like
int eval(Integer, String) . |
static ExtractionUtils.AssigningConstructor |
extractAssigningConstructor(Class<?> clazz,
List<Field> fields)
Checks whether the given constructor takes all of the given fields with matching (possibly
primitive) type and name.
|
static Optional<Class<?>> |
extractSimpleGeneric(Class<?> baseClass,
Class<?> clazz,
int pos)
A minimal version to extract a generic parameter from a given class.
|
static Field |
getStructuredField(Class<?> clazz,
String fieldName)
Returns the field of a structured type.
|
static Optional<Method> |
getStructuredFieldGetter(Class<?> clazz,
Field field)
Checks for a field getter of a structured type.
|
static Optional<Method> |
getStructuredFieldSetter(Class<?> clazz,
Field field)
Checks for a field setters of a structured type.
|
static boolean |
hasInvokableConstructor(Class<?> clazz,
Class<?>... classes)
Checks for an invokable constructor matching the given arguments.
|
static boolean |
isAssignable(Class<?> cls,
Class<?> toClass,
boolean autoboxing)
Checks if one
Class can be assigned to a variable of another Class . |
static boolean |
isInvokable(Executable executable,
Class<?>... classes)
Checks whether a method/constructor can be called with the given argument classes.
|
static boolean |
isStructuredFieldDirectlyReadable(Field field)
Checks whether a field is directly readable without a getter.
|
static boolean |
isStructuredFieldDirectlyWritable(Field field)
Checks whether a field is directly writable without a setter or constructor.
|
static Class<?> |
primitiveToWrapper(Class<?> cls)
Converts the specified primitive Class object to its corresponding wrapper Class object.
|
static void |
validateStructuredClass(Class<?> clazz)
Validates the characteristics of a class for a
StructuredType such as accessibility. |
static Class<?> |
wrapperToPrimitive(Class<?> cls)
Converts the specified wrapper class to its corresponding primitive class.
|
public static List<Method> collectMethods(Class<?> function, String methodName)
public static boolean isInvokable(Executable executable, Class<?>... classes)
null
is a wildcard.
E.g., (int.class, int.class)
matches f(Object...), f(int, int), f(Integer,
Object)
and so forth.
public static String createMethodSignatureString(String methodName, Class<?>[] parameters, @Nullable Class<?> returnType)
int eval(Integer, String)
.public static void validateStructuredClass(Class<?> clazz)
StructuredType
such as accessibility.public static Field getStructuredField(Class<?> clazz, String fieldName)
public static Optional<Method> getStructuredFieldGetter(Class<?> clazz, Field field)
public static Optional<Method> getStructuredFieldSetter(Class<?> clazz, Field field)
public static boolean hasInvokableConstructor(Class<?> clazz, Class<?>... classes)
isInvokable(Executable, Class[])
public static boolean isStructuredFieldDirectlyReadable(Field field)
public static boolean isStructuredFieldDirectlyWritable(Field field)
public static Optional<Class<?>> extractSimpleGeneric(Class<?> baseClass, Class<?> clazz, int pos)
This method should only be used for very specific use cases, in most cases DataTypeExtractor.extractFromGeneric(DataTypeFactory, Class, int, Type)
should be more
appropriate.
@Nullable public static ExtractionUtils.AssigningConstructor extractAssigningConstructor(Class<?> clazz, List<Field> fields)
public static boolean isAssignable(Class<?> cls, Class<?> toClass, boolean autoboxing)
Class
can be assigned to a variable of another Class
.
Unlike the Class.isAssignableFrom(java.lang.Class)
method, this method takes into
account widenings of primitive classes and null
s.
Primitive widenings allow an int to be assigned to a long, float or double. This method returns the correct result for these cases.
Null
may be assigned to any reference type. This method will return true
if null
is passed in and the toClass is non-primitive.
Specifically, this method tests whether the type represented by the specified Class
parameter can be converted to the type represented by this Class
object via an
identity conversion widening primitive or widening reference conversion. See The Java Language Specification,
sections 5.1.1, 5.1.2 and 5.1.4 for details.
cls
- the Class to check, may be nulltoClass
- the Class to try to assign into, returns false if nullautoboxing
- whether to use implicit autoboxing/unboxing between primitives and wrapperstrue
if assignment possiblepublic static Class<?> primitiveToWrapper(Class<?> cls)
NOTE: From v2.2, this method handles Void.TYPE
, returning Void.TYPE
.
cls
- the class to convert, may be nullcls
or cls
if cls
is not a primitive.
null
if null input.public static Class<?> wrapperToPrimitive(Class<?> cls)
This method is the counter part of primitiveToWrapper()
. If the passed in class is
a wrapper class for a primitive type, this primitive type will be returned (e.g. Integer.TYPE
for Integer.class
). For other classes, or if the parameter is
null, the return value is null.
cls
- the class to convert, may be nullcls
is a wrapper class, null
otherwiseprimitiveToWrapper(Class)
public static Class<?> classForName(String name, boolean initialize, ClassLoader classLoader) throws ClassNotFoundException
Class.forName(String, boolean, ClassLoader)
but resolves primitive names
as well.ClassNotFoundException
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.