public class BeanUtil extends Object
PropertyChangeListener
.Modifier and Type | Field and Description |
---|---|
static String |
ADD_PROPERTY_CHANGE_LISTENER |
static com.google.common.base.Predicate<PropertyDescriptor> |
IS_READ_AND_WRITE_DESCRIPTOR
Is a property is readable and writable ?
|
static com.google.common.base.Predicate<PropertyDescriptor> |
IS_READ_DESCRIPTOR
Is a property is readable ?
|
static com.google.common.base.Predicate<PropertyDescriptor> |
IS_WRITE_DESCRIPTOR
Is a property is writable ?
|
static String |
REMOVE_PROPERTY_CHANGE_LISTENER |
Modifier | Constructor and Description |
---|---|
protected |
BeanUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
addPropertyChangeListener(PropertyChangeListener listener,
Object bean)
Add the given
listener to the given bean using the
normalized method named addPropertyChangeListener . |
static Set<PropertyDescriptor> |
getDescriptors(Class<?> beanType,
com.google.common.base.Predicate<PropertyDescriptor> predicate)
Scan the given type and obtain
PropertyDescriptor
given the (optional) predicate (except the class property of
any java object). |
protected static void |
getDescriptors(Class<?> beanType,
com.google.common.base.Predicate<PropertyDescriptor> predicate,
Map<String,PropertyDescriptor> result,
Set<Class<?>> exploredTypes) |
static Method |
getMutator(Object bean,
String property) |
static Set<String> |
getReadableProperties(Class<?> beanType)
Obtains all readable properties from a given type.
|
protected static void |
getReadableProperties(Class<?> beanType,
Set<String> result) |
protected static void |
getReadableProperties(Class<?> beanType,
Set<String> result,
Set<Class<?>> exploredTypes) |
static Class<?> |
getReadableType(Class<?> beanType,
String propertyName) |
static Set<String> |
getWriteableProperties(Class<?> beanType)
Obtains all writeable properties from a given type.
|
protected static void |
getWriteableProperties(Class<?> beanType,
Set<String> result) |
protected static void |
getWriteableProperties(Class<?> beanType,
Set<String> result,
Set<Class<?>> exploredTypes) |
static boolean |
isJavaBeanCompiliant(Class<?> type)
Test if the given type is JavaBean compiliant, says that it has two
public methods :
addPropertyChangeListener
removePropertyChangeListener
|
static boolean |
isNestedReadableProperty(Class<?> beanType,
String propertyName)
Obtains all readable properties from a given type.
|
static void |
removePropertyChangeListener(PropertyChangeListener listener,
Object bean)
Remove the given
listener from the given bean using the
normalized method named removePropertyChangeListener . |
public static final String ADD_PROPERTY_CHANGE_LISTENER
public static final String REMOVE_PROPERTY_CHANGE_LISTENER
public static final com.google.common.base.Predicate<PropertyDescriptor> IS_READ_DESCRIPTOR
public static final com.google.common.base.Predicate<PropertyDescriptor> IS_WRITE_DESCRIPTOR
public static final com.google.common.base.Predicate<PropertyDescriptor> IS_READ_AND_WRITE_DESCRIPTOR
public static boolean isJavaBeanCompiliant(Class<?> type)
addPropertyChangeListener
removePropertyChangeListener
type
- type to testtrue
if type is Javabean compiliant, false
otherwisepublic static void addPropertyChangeListener(PropertyChangeListener listener, Object bean) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException
listener
to the given bean
using the
normalized method named addPropertyChangeListener
.listener
- the listener to addbean
- the bean on which the listener is addedInvocationTargetException
- if could not invoke the method
addPropertyChangeListener
NoSuchMethodException
- if method
addPropertyChangeListener
does not exist on given beanIllegalAccessException
- if an illegal access occurs when
invoking the method
addPropertyChangeListener
public static void removePropertyChangeListener(PropertyChangeListener listener, Object bean) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException
listener
from the given bean
using the
normalized method named removePropertyChangeListener
.listener
- the listener to removebean
- the bean on which the listener is removedInvocationTargetException
- if could not invoke the method
removePropertyChangeListener
NoSuchMethodException
- if method
removePropertyChangeListener
does not exist on given beanIllegalAccessException
- if an illegal access occurs when
invoking the method
removePropertyChangeListener
public static Set<String> getReadableProperties(Class<?> beanType)
beanType
- the type to seekpublic static Set<String> getWriteableProperties(Class<?> beanType)
beanType
- the type to seekpublic static boolean isNestedReadableProperty(Class<?> beanType, String propertyName)
beanType
- the type to seekpropertyName
- FIXMEpublic static Set<PropertyDescriptor> getDescriptors(Class<?> beanType, com.google.common.base.Predicate<PropertyDescriptor> predicate)
PropertyDescriptor
given the (optional) predicate (except the class
property of
any java object).
Note: If no predicate is given, then all descriptors
are returned.beanType
- the bean type to scanpredicate
- the optional predicate to keep descriptorprotected static void getDescriptors(Class<?> beanType, com.google.common.base.Predicate<PropertyDescriptor> predicate, Map<String,PropertyDescriptor> result, Set<Class<?>> exploredTypes)
protected static void getReadableProperties(Class<?> beanType, Set<String> result, Set<Class<?>> exploredTypes)
protected static void getReadableProperties(Class<?> beanType, Set<String> result)
protected static void getWriteableProperties(Class<?> beanType, Set<String> result, Set<Class<?>> exploredTypes)
Copyright © 2004–2020 CodeLutin. All rights reserved.