Top Description Inners Fields Constructors Methods
org.springframework.beans

public abstract Class BeanUtils

extends Object
Class Inheritance
Imports
java.beans.ConstructorProperties, .PropertyDescriptor, .PropertyEditor, java.lang.reflect.Constructor, .InvocationTargetException, .Method, .Modifier, .Type, java.util.Arrays, .Collections, .HashSet, .List, .Map, .Set, kotlin.jvm.JvmClassMappingKt, kotlin.jvm.JvmInline, kotlin.reflect.KClass, kotlin.reflect.KFunction, kotlin.reflect.KParameter, kotlin.reflect.full.KAnnotatedElements, kotlin.reflect.full.KClasses, kotlin.reflect.jvm.KCallablesJvm, kotlin.reflect.jvm.ReflectJvmMapping, org.springframework.core.DefaultParameterNameDiscoverer, .KotlinDetector, .MethodParameter, .ParameterNameDiscoverer, .ResolvableType, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils, .CollectionUtils, .ConcurrentReferenceHashMap, .ReflectionUtils, .StringUtils

Static convenience methods for JavaBeans: for instantiating beans, checking bean property types, copying bean properties, etc.

Mainly for internal use within the framework, but to some degree also useful for application classes. Consider Apache Commons BeanUtils, BULL - Bean Utils Light Library, or similar third-party frameworks for more comprehensive bean utilities.

Authors
Rod Johnson, Juergen Hoeller, Rob Harrop, Sam Brannen, Sebastien Deleuze

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
BeanUtils.KotlinDelegate

Inner class to avoid a hard dependency on Kotlin at runtime.

Field Summary

Modifier and TypeField and Description
private static final Map<Class<?>, Object>
private static final ParameterNameDiscoverer
private static final Set<Class<?>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
copyProperties(Object
the source bean
source
,
Object
the target bean
target
)

Copy the property values of the given source bean into the target bean.

public static void
copyProperties(Object
the source bean
source
,
Object
the target bean
target
,
Class<?>
the class (or interface) to restrict property setting to
editable
)

Copy the property values of the given source bean into the given target bean, only setting properties defined in the given "editable" class (or interface).

public static void
copyProperties(Object
the source bean
source
,
Object
the target bean
target
,
String...
array of property names to ignore
ignoreProperties
)

Copy the property values of the given source bean into the given target bean, ignoring the given "ignoreProperties".

private static void
copyProperties(Object
the source bean
source
,
Object
the target bean
target
,
Class<?>
the class (or interface) to restrict property setting to
editable
,
String...
array of property names to ignore
ignoreProperties
)

Copy the property values of the given source bean into the given target bean.

public static Method

Returns:

the Method object, or null if not found
findDeclaredMethod
(Class<?>
the class to check
clazz
,
String
the name of the method to find
methodName
,
Class<?>...
the parameter types of the method to find
paramTypes
)

Find a method with the given method name and the given parameter types, declared on the given class or one of its superclasses.

public static Method

Returns:

the Method object, or null if not found
findDeclaredMethodWithMinimalParameters
(Class<?>
the class to check
clazz
,
String
the name of the method to find
methodName
)

Find a method with the given method name and minimal parameters (best case: none), declared on the given class or one of its superclasses.

public static PropertyEditor

Returns:

the corresponding editor, or null if none found
findEditorByConvention
(Class<?>
the type to find an editor for
targetType
)

Find a JavaBeans PropertyEditor following the 'Editor' suffix convention (e.g. "mypackage.MyDomainClass" → "mypackage.MyDomainClassEditor").

public static Method

Returns:

the Method object, or null if not found
findMethod
(Class<?>
the class to check
clazz
,
String
the name of the method to find
methodName
,
Class<?>...
the parameter types of the method to find
paramTypes
)

Find a method with the given method name and the given parameter types, declared on the given class or one of its superclasses.

public static Method

Returns:

the Method object, or null if not found
findMethodWithMinimalParameters
(Class<?>
the class to check
clazz
,
String
the name of the method to find
methodName
)

Find a method with the given method name and minimal parameters (best case: none), declared on the given class or one of its superclasses.

public static Method

Returns:

the Method object, or null if not found
findMethodWithMinimalParameters
(Method[]
the methods to check
methods
,
String
the name of the method to find
methodName
)

Find a method with the given method name and minimal parameters (best case: none) in the given list of methods.

public static <T> Constructor<T>
findPrimaryConstructor(Class<T>
the class to check
clazz
)

Return the primary constructor of the provided class.

public static PropertyDescriptor

Returns:

the corresponding PropertyDescriptor, or null if none
findPropertyForMethod
(Method
the method to find a corresponding PropertyDescriptor for, introspecting its declaring class
method
)

Find a JavaBeans PropertyDescriptor for the given method, with the method either being the read method or the write method for that bean property.

public static PropertyDescriptor

Returns:

the corresponding PropertyDescriptor, or null if none
findPropertyForMethod
(Method
the method to find a corresponding PropertyDescriptor for
method
,
Class<?>
the (most specific) class to introspect for descriptors
clazz
)

Find a JavaBeans PropertyDescriptor for the given method, with the method either being the read method or the write method for that bean property.

public static Class<?>

Returns:

the property type, or Object.class as fallback
findPropertyType
(String
the name of the bean property
propertyName
,
Class<?>...
the classes to check against
beanClasses
)

Determine the bean property type for the given property from the given classes/interfaces, if possible.

public static String[]

Returns:

the parameter names (matching the constructor's parameter count)
getParameterNames
(Constructor<?>
the constructor to find parameter names for
ctor
)

Determine required parameter names for the given constructor, considering the JavaBeans ConstructorProperties annotation as well as Spring's DefaultParameterNameDiscoverer.

public static PropertyDescriptor

Returns:

the corresponding PropertyDescriptor, or null if none
getPropertyDescriptor
(Class<?>
the Class to retrieve the PropertyDescriptor for
clazz
,
String
the name of the property
propertyName
)

Retrieve the JavaBeans PropertyDescriptors for the given property.

public static PropertyDescriptor[]

Returns:

an array of PropertyDescriptors for the given class
getPropertyDescriptors
(Class<?>
the Class to retrieve the PropertyDescriptors for
clazz
)

Retrieve the JavaBeans PropertyDescriptors of a given class.

public static <T> Constructor<T>
getResolvableConstructor(Class<T>
the class to check
clazz
)

Return a resolvable constructor for the provided class, either a primary or single public constructor with arguments, or a single non-public constructor with arguments, or simply a default constructor.

public static MethodParameter

Returns:

a corresponding MethodParameter object
getWriteMethodParameter
(PropertyDescriptor
the PropertyDescriptor for the property
pd
)

Obtain a new MethodParameter object for the write method of the specified property.

public static boolean

Returns:

true if writable and unique, false otherwise
hasUniqueWriteMethod
(PropertyDescriptor
the PropertyDescriptor for the property
pd
)

Determine whether the specified property has a unique write method, i.e. is writable but does not declare overloaded setter methods.

public static <T> T

Returns:

the new instance
instantiate
(Class<T>
class to instantiate
clazz
)
Deprecated as of Spring 5.0, following the deprecation of Class#newInstance() in JDK 9

Convenience method to instantiate a class using its no-arg constructor.

public static <T> T

Returns:

the new instance
instantiateClass
(Class<T>
the class to instantiate
clazz
)

Instantiate a class using its 'primary' constructor (for Kotlin classes, potentially having default arguments declared) or its default constructor (for regular Java classes, expecting a standard no-arg setup).

public static <T> T

Returns:

the new instance
instantiateClass
(Class<?>
class to instantiate
clazz
,
Class<T>
type that clazz must be assignableTo
assignableTo
)

Instantiate a class using its no-arg constructor and return the new instance as the specified assignable type.

public static <T> T

Returns:

the new instance
instantiateClass
(Constructor<T>
the constructor to instantiate
ctor
,
Object...
the constructor arguments to apply (use null for an unspecified parameter, Kotlin optional parameters and Java primitive types are supported)
args
)

Convenience method to instantiate a class using the given constructor.

private static boolean
isAssignable(Method writeMethod, Method readMethod, PropertyDescriptor sourcePd, PropertyDescriptor targetPd)

public static boolean

Returns:

whether the given type represents a "simple" property
isSimpleProperty
(Class<?>
the type to check
type
)

Check if the given type represents a "simple" property: a simple value type or an array of simple value types.

public static boolean

Returns:

whether the given type represents a "simple" value type
isSimpleValueType
(Class<?>
the type to check
type
)

Check if the given type represents a "simple" value type for bean property and data binding purposes: a primitive or primitive wrapper, an Enum, a String or other CharSequence, a Number, a Date, a Temporal, a UUID, a URI, a URL, a Locale, or a Class.

public static Method

Returns:

the resolved Method
resolveSignature
(String
the method signature as String representation
signature
,
Class<?>
the class to resolve the method signature against
clazz
)

Parse a method signature in the form methodName[([arg_list])], where arg_list is an optional, comma-separated list of fully-qualified type names, and attempts to resolve that signature against the supplied Class.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_TYPE_VALUESback to summary
private static final Map<Class<?>, Object> DEFAULT_TYPE_VALUES
parameterNameDiscovererback to summary
private static final ParameterNameDiscoverer parameterNameDiscoverer
unknownEditorTypesback to summary
private static final Set<Class<?>> unknownEditorTypes

Constructor Detail

BeanUtilsback to summary
public BeanUtils()

Method Detail

copyPropertiesback to summary
public static void copyProperties(Object source, Object target) throws BeansException

Copy the property values of the given source bean into the target bean.

Note

The source and target classes do not have to match or even be derived from each other, as long as the properties match. Any bean properties that the source bean exposes but the target bean does not will silently be ignored.

This is just a convenience method. For more complex transfer needs, consider using a full BeanWrapper.

As of Spring Framework 5.3, this method honors generic type information when matching properties in the source and target objects.

The following table provides a non-exhaustive set of examples of source and target property types that can be copied as well as source and target property types that cannot be copied.

source property typetarget property typecopy supported
IntegerIntegeryes
IntegerNumberyes
List<Integer>List<Integer>yes
List<?>List<?>yes
List<Integer>List<?>yes
List<Integer>List<? extends Number>yes
StringIntegerno
NumberIntegerno
List<Integer>List<Long>no
List<Integer>List<Number>no
Parameters
source:Object

the source bean

target:Object

the target bean

Exceptions
BeansException:
if the copying failed
See Also
BeanWrapper
copyPropertiesback to summary
public static void copyProperties(Object source, Object target, Class<?> editable) throws BeansException

Copy the property values of the given source bean into the given target bean, only setting properties defined in the given "editable" class (or interface).

Note

The source and target classes do not have to match or even be derived from each other, as long as the properties match. Any bean properties that the source bean exposes but the target bean does not will silently be ignored.

This is just a convenience method. For more complex transfer needs, consider using a full BeanWrapper.

As of Spring Framework 5.3, this method honors generic type information when matching properties in the source and target objects. See the documentation for copyProperties(Object, Object) for details.

Parameters
source:Object

the source bean

target:Object

the target bean

editable:Class<?>

the class (or interface) to restrict property setting to

Exceptions
BeansException:
if the copying failed
See Also
BeanWrapper
copyPropertiesback to summary
public static void copyProperties(Object source, Object target, String... ignoreProperties) throws BeansException

Copy the property values of the given source bean into the given target bean, ignoring the given "ignoreProperties".

Note

The source and target classes do not have to match or even be derived from each other, as long as the properties match. Any bean properties that the source bean exposes but the target bean does not will silently be ignored.

This is just a convenience method. For more complex transfer needs, consider using a full BeanWrapper.

As of Spring Framework 5.3, this method honors generic type information when matching properties in the source and target objects. See the documentation for copyProperties(Object, Object) for details.

Parameters
source:Object

the source bean

target:Object

the target bean

ignoreProperties:String[]

array of property names to ignore

Exceptions
BeansException:
if the copying failed
See Also
BeanWrapper
copyPropertiesback to summary
private static void copyProperties(Object source, Object target, Class<?> editable, String... ignoreProperties) throws BeansException

Copy the property values of the given source bean into the given target bean.

Note

The source and target classes do not have to match or even be derived from each other, as long as the properties match. Any bean properties that the source bean exposes but the target bean does not will silently be ignored.

As of Spring Framework 5.3, this method honors generic type information when matching properties in the source and target objects. See the documentation for copyProperties(Object, Object) for details.

Parameters
source:Object

the source bean

target:Object

the target bean

editable:Class<?>

the class (or interface) to restrict property setting to

ignoreProperties:String[]

array of property names to ignore

Exceptions
BeansException:
if the copying failed
See Also
BeanWrapper
findDeclaredMethodback to summary
public static Method findDeclaredMethod(Class<?> clazz, String methodName, Class<?>... paramTypes)

Find a method with the given method name and the given parameter types, declared on the given class or one of its superclasses. Will return a public, protected, package access, or private method.

Checks Class.getDeclaredMethod, cascading upwards to all superclasses.

Parameters
clazz:Class<?>

the class to check

methodName:String

the name of the method to find

paramTypes:Class<?>[]

the parameter types of the method to find

Returns:Method

the Method object, or null if not found

Annotations
@Nullable
See Also
Class#getDeclaredMethod
findDeclaredMethodWithMinimalParametersback to summary
public static Method findDeclaredMethodWithMinimalParameters(Class<?> clazz, String methodName) throws IllegalArgumentException

Find a method with the given method name and minimal parameters (best case: none), declared on the given class or one of its superclasses. Will return a public, protected, package access, or private method.

Checks Class.getDeclaredMethods, cascading upwards to all superclasses.

Parameters
clazz:Class<?>

the class to check

methodName:String

the name of the method to find

Returns:Method

the Method object, or null if not found

Annotations
@Nullable
Exceptions
IllegalArgumentException:
if methods of the given name were found but could not be resolved to a unique method with minimal parameters
See Also
Class#getDeclaredMethods
findEditorByConventionback to summary
public static PropertyEditor findEditorByConvention(Class<?> targetType)

Find a JavaBeans PropertyEditor following the 'Editor' suffix convention (e.g. "mypackage.MyDomainClass" → "mypackage.MyDomainClassEditor").

Compatible to the standard JavaBeans convention as implemented by java.beans.PropertyEditorManager but isolated from the latter's registered default editors for primitive types.

Parameters
targetType:Class<?>

the type to find an editor for

Returns:PropertyEditor

the corresponding editor, or null if none found

Annotations
@Nullable
findMethodback to summary
public static Method findMethod(Class<?> clazz, String methodName, Class<?>... paramTypes)

Find a method with the given method name and the given parameter types, declared on the given class or one of its superclasses. Prefers public methods, but will return a protected, package access, or private method too.

Checks Class.getMethod first, falling back to findDeclaredMethod. This allows to find public methods without issues even in environments with restricted Java security settings.

Parameters
clazz:Class<?>

the class to check

methodName:String

the name of the method to find

paramTypes:Class<?>[]

the parameter types of the method to find

Returns:Method

the Method object, or null if not found

Annotations
@Nullable
See Also
Class#getMethod, findDeclaredMethod
findMethodWithMinimalParametersback to summary
public static Method findMethodWithMinimalParameters(Class<?> clazz, String methodName) throws IllegalArgumentException

Find a method with the given method name and minimal parameters (best case: none), declared on the given class or one of its superclasses. Prefers public methods, but will return a protected, package access, or private method too.

Checks Class.getMethods first, falling back to findDeclaredMethodWithMinimalParameters. This allows for finding public methods without issues even in environments with restricted Java security settings.

Parameters
clazz:Class<?>

the class to check

methodName:String

the name of the method to find

Returns:Method

the Method object, or null if not found

Annotations
@Nullable
Exceptions
IllegalArgumentException:
if methods of the given name were found but could not be resolved to a unique method with minimal parameters
See Also
Class#getMethods, findDeclaredMethodWithMinimalParameters
findMethodWithMinimalParametersback to summary
public static Method findMethodWithMinimalParameters(Method[] methods, String methodName) throws IllegalArgumentException

Find a method with the given method name and minimal parameters (best case: none) in the given list of methods.

Parameters
methods:Method[]

the methods to check

methodName:String

the name of the method to find

Returns:Method

the Method object, or null if not found

Annotations
@Nullable
Exceptions
IllegalArgumentException:
if methods of the given name were found but could not be resolved to a unique method with minimal parameters
findPrimaryConstructorback to summary
public static <T> Constructor<T> findPrimaryConstructor(Class<T> clazz)

Return the primary constructor of the provided class. For Kotlin classes, this returns the Java constructor corresponding to the Kotlin primary constructor (as defined in the Kotlin specification). Otherwise, in particular for non-Kotlin classes, this simply returns null.

Parameters
clazz:Class<T>

the class to check

Annotations
@Nullable
Since
5.0
See Also
Kotlin docs
findPropertyForMethodback to summary
public static PropertyDescriptor findPropertyForMethod(Method method) throws BeansException

Find a JavaBeans PropertyDescriptor for the given method, with the method either being the read method or the write method for that bean property.

Parameters
method:Method

the method to find a corresponding PropertyDescriptor for, introspecting its declaring class

Returns:PropertyDescriptor

the corresponding PropertyDescriptor, or null if none

Annotations
@Nullable
Exceptions
BeansException:
if PropertyDescriptor lookup fails
findPropertyForMethodback to summary
public static PropertyDescriptor findPropertyForMethod(Method method, Class<?> clazz) throws BeansException

Find a JavaBeans PropertyDescriptor for the given method, with the method either being the read method or the write method for that bean property.

Parameters
method:Method

the method to find a corresponding PropertyDescriptor for

clazz:Class<?>

the (most specific) class to introspect for descriptors

Returns:PropertyDescriptor

the corresponding PropertyDescriptor, or null if none

Annotations
@Nullable
Exceptions
BeansException:
if PropertyDescriptor lookup fails
Since
3.2.13
findPropertyTypeback to summary
public static Class<?> findPropertyType(String propertyName, Class<?>... beanClasses)

Determine the bean property type for the given property from the given classes/interfaces, if possible.

Parameters
propertyName:String

the name of the bean property

beanClasses:Class<?>[]

the classes to check against

Returns:Class<?>

the property type, or Object.class as fallback

getParameterNamesback to summary
public static String[] getParameterNames(Constructor<?> ctor)

Determine required parameter names for the given constructor, considering the JavaBeans ConstructorProperties annotation as well as Spring's DefaultParameterNameDiscoverer.

Parameters
ctor:Constructor<?>

the constructor to find parameter names for

Returns:String[]

the parameter names (matching the constructor's parameter count)

Exceptions
IllegalStateException:
if the parameter names are not resolvable
Since
5.3
See Also
ConstructorProperties, DefaultParameterNameDiscoverer
getPropertyDescriptorback to summary
public static PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String propertyName) throws BeansException

Retrieve the JavaBeans PropertyDescriptors for the given property.

Parameters
clazz:Class<?>

the Class to retrieve the PropertyDescriptor for

propertyName:String

the name of the property

Returns:PropertyDescriptor

the corresponding PropertyDescriptor, or null if none

Annotations
@Nullable
Exceptions
BeansException:
if PropertyDescriptor lookup fails
getPropertyDescriptorsback to summary
public static PropertyDescriptor[] getPropertyDescriptors(Class<?> clazz) throws BeansException

Retrieve the JavaBeans PropertyDescriptors of a given class.

Parameters
clazz:Class<?>

the Class to retrieve the PropertyDescriptors for

Returns:PropertyDescriptor[]

an array of PropertyDescriptors for the given class

Exceptions
BeansException:
if PropertyDescriptor look fails
getResolvableConstructorback to summary
public static <T> Constructor<T> getResolvableConstructor(Class<T> clazz)

Return a resolvable constructor for the provided class, either a primary or single public constructor with arguments, or a single non-public constructor with arguments, or simply a default constructor. Callers have to be prepared to resolve arguments for the returned constructor's parameters, if any.

Parameters
clazz:Class<T>

the class to check

Annotations
@SuppressWarnings:unchecked
Exceptions
IllegalStateException:
in case of no unique constructor found at all
Since
5.3
See Also
findPrimaryConstructor
getWriteMethodParameterback to summary
public static MethodParameter getWriteMethodParameter(PropertyDescriptor pd)

Obtain a new MethodParameter object for the write method of the specified property.

Parameters
pd:PropertyDescriptor

the PropertyDescriptor for the property

Returns:MethodParameter

a corresponding MethodParameter object

hasUniqueWriteMethodback to summary
public static boolean hasUniqueWriteMethod(PropertyDescriptor pd)

Determine whether the specified property has a unique write method, i.e. is writable but does not declare overloaded setter methods.

Parameters
pd:PropertyDescriptor

the PropertyDescriptor for the property

Returns:boolean

true if writable and unique, false otherwise

Since
6.1.4
instantiateback to summary
public static <T> T instantiate(Class<T> clazz) throws BeanInstantiationException

Deprecated

as of Spring 5.0, following the deprecation of Class#newInstance() in JDK 9

Convenience method to instantiate a class using its no-arg constructor.

Parameters
clazz:Class<T>

class to instantiate

Returns:T

the new instance

Annotations
@Deprecated
Exceptions
BeanInstantiationException:
if the bean cannot be instantiated
See Also
Class#newInstance()
instantiateClassback to summary
public static <T> T instantiateClass(Class<T> clazz) throws BeanInstantiationException

Instantiate a class using its 'primary' constructor (for Kotlin classes, potentially having default arguments declared) or its default constructor (for regular Java classes, expecting a standard no-arg setup).

Note that this method tries to set the constructor accessible if given a non-accessible (that is, non-public) constructor.

Parameters
clazz:Class<T>

the class to instantiate

Returns:T

the new instance

Exceptions
BeanInstantiationException:
if the bean cannot be instantiated. The cause may notably indicate a NoSuchMethodException if no primary/default constructor was found, a NoClassDefFoundError or other LinkageError in case of an unresolvable class definition (e.g. due to a missing dependency at runtime), or an exception thrown from the constructor invocation itself.
See Also
Constructor#newInstance
instantiateClassback to summary
public static <T> T instantiateClass(Class<?> clazz, Class<T> assignableTo) throws BeanInstantiationException

Instantiate a class using its no-arg constructor and return the new instance as the specified assignable type.

Useful in cases where the type of the class to instantiate (clazz) is not available, but the type desired (assignableTo) is known.

Note that this method tries to set the constructor accessible if given a non-accessible (that is, non-public) constructor.

Parameters
clazz:Class<?>

class to instantiate

assignableTo:Class<T>

type that clazz must be assignableTo

Returns:T

the new instance

Annotations
@SuppressWarnings:unchecked
Exceptions
BeanInstantiationException:
if the bean cannot be instantiated
See Also
Constructor#newInstance
instantiateClassback to summary
public static <T> T instantiateClass(Constructor<T> ctor, Object... args) throws BeanInstantiationException

Convenience method to instantiate a class using the given constructor.

Note that this method tries to set the constructor accessible if given a non-accessible (that is, non-public) constructor, and supports Kotlin classes with optional parameters and default values.

Parameters
ctor:Constructor<T>

the constructor to instantiate

args:Object[]

the constructor arguments to apply (use null for an unspecified parameter, Kotlin optional parameters and Java primitive types are supported)

Returns:T

the new instance

Exceptions
BeanInstantiationException:
if the bean cannot be instantiated
See Also
Constructor#newInstance
isAssignableback to summary
private static boolean isAssignable(Method writeMethod, Method readMethod, PropertyDescriptor sourcePd, PropertyDescriptor targetPd)
isSimplePropertyback to summary
public static boolean isSimpleProperty(Class<?> type)

Check if the given type represents a "simple" property: a simple value type or an array of simple value types.

See isSimpleValueType(Class) for the definition of simple value type.

Used to determine properties to check for a "simple" dependency-check.

Parameters
type:Class<?>

the type to check

Returns:boolean

whether the given type represents a "simple" property

See Also
org.springframework.beans.factory.support.RootBeanDefinition#DEPENDENCY_CHECK_SIMPLE, org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#checkDependencies, isSimpleValueType(Class)
isSimpleValueTypeback to summary
public static boolean isSimpleValueType(Class<?> type)

Check if the given type represents a "simple" value type for bean property and data binding purposes: a primitive or primitive wrapper, an Enum, a String or other CharSequence, a Number, a Date, a Temporal, a UUID, a URI, a URL, a Locale, or a Class.

Void and void are not considered simple value types.

As of 6.1, this method delegates to ClassUtils#isSimpleValueType as-is but could potentially add further rules for bean property purposes.

Parameters
type:Class<?>

the type to check

Returns:boolean

whether the given type represents a "simple" value type

See Also
isSimpleProperty(Class), ClassUtils#isSimpleValueType(Class)
resolveSignatureback to summary
public static Method resolveSignature(String signature, Class<?> clazz)

Parse a method signature in the form methodName[([arg_list])], where arg_list is an optional, comma-separated list of fully-qualified type names, and attempts to resolve that signature against the supplied Class.

When not supplying an argument list (methodName) the method whose name matches and has the least number of parameters will be returned. When supplying an argument type list, only the method whose name and argument types match will be returned.

Note then that methodName and methodName() are not resolved in the same way. The signature methodName means the method called methodName with the least number of arguments, whereas methodName() means the method called methodName with exactly 0 arguments.

If no method can be found, then null is returned.

Parameters
signature:String

the method signature as String representation

clazz:Class<?>

the class to resolve the method signature against

Returns:Method

the resolved Method

Annotations
@Nullable
See Also
findMethod, findMethodWithMinimalParameters
org.springframework.beans back to summary

private Class BeanUtils.KotlinDelegate

extends Object
Class Inheritance

Inner class to avoid a hard dependency on Kotlin at runtime.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <T> Constructor<T>
findPrimaryConstructor(Class<T>
the Class of the Kotlin class
clazz
)

Retrieve the Java constructor corresponding to the Kotlin primary constructor, if any.

public static <T> T
instantiateClass(Constructor<T>
the constructor of the Kotlin class to instantiate
ctor
,
Object...
the constructor arguments to apply (use null for unspecified parameter if needed)
args
)

Instantiate a Kotlin class using the provided constructor.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

KotlinDelegateback to summary
private KotlinDelegate()

Method Detail

findPrimaryConstructorback to summary
public static <T> Constructor<T> findPrimaryConstructor(Class<T> clazz)

Retrieve the Java constructor corresponding to the Kotlin primary constructor, if any.

Parameters
clazz:Class<T>

the Class of the Kotlin class

Annotations
@SuppressWarnings:unchecked
@Nullable
See Also
https://kotlinlang.org/docs/reference/classes.html#constructors
instantiateClassback to summary
public static <T> T instantiateClass(Constructor<T> ctor, Object... args) throws IllegalAccessException, InvocationTargetException, InstantiationException

Instantiate a Kotlin class using the provided constructor.

Parameters
ctor:Constructor<T>

the constructor of the Kotlin class to instantiate

args:Object[]

the constructor arguments to apply (use null for unspecified parameter if needed)