public final class BeanUtil extends Object implements Serializable
For internal use only. May be renamed or removed in a future release.
Modifier and Type | Method and Description |
---|---|
static boolean |
checkBeanValidationAvailable()
Returns whether an implementation of JSR-303 version 1.0 or 1.1 is
present on the classpath.
|
static List<PropertyDescriptor> |
getBeanPropertyDescriptors(Class<?> beanType)
Returns the property descriptors of a class or an interface.
|
static PropertyDescriptor |
getPropertyDescriptor(Class<?> beanType,
String propertyName)
Returns the property descriptor for the property of the given name and
declaring class.
|
static Class<?> |
getPropertyType(Class<?> beanType,
String propertyName)
Returns the type of the property with the given name and declaring class.
|
public static List<PropertyDescriptor> getBeanPropertyDescriptors(Class<?> beanType) throws IntrospectionException
NOTE : This utility method relies on introspection (and returns PropertyDescriptor) which is a part of java.beans package. The latter package could require bigger JDK in the future (with Java 9+). So it may be changed in the future.
For interfaces, the iteration is depth first and the properties of superinterfaces are returned before those of their subinterfaces.
beanType
- the type whose properties to queryIntrospectionException
- if the introspection failspublic static Class<?> getPropertyType(Class<?> beanType, String propertyName) throws IntrospectionException
beanType
- the type declaring the propertypropertyName
- the name of the propertyIntrospectionException
- if the introspection failspublic static PropertyDescriptor getPropertyDescriptor(Class<?> beanType, String propertyName) throws IntrospectionException
beanType
- the type declaring the propertypropertyName
- the name of the propertyIntrospectionException
- if the introspection failspublic static boolean checkBeanValidationAvailable()
BeanValidator
instance will throw an
IllegalStateException
. If an implementation is not found, logs a
level FINE
message the first time it is run.true
if bean validation is available, false
otherwise.Copyright © 2023. All rights reserved.