Class BeanUtil
java.lang.Object
org.nuiton.util.beans.BeanUtil
Usefull methods around the
PropertyChangeListener.- Since:
- 1.4.1
- Author:
- Tony Chemit - chemit@codelutin.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final com.google.common.base.Predicate<PropertyDescriptor> Is a property is readable and writable ?static final com.google.common.base.Predicate<PropertyDescriptor> Is a property is readable ?static final com.google.common.base.Predicate<PropertyDescriptor> Is a property is writable ?static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddPropertyChangeListener(PropertyChangeListener listener, Object bean) Add the givenlistenerto the givenbeanusing the normalized method namedaddPropertyChangeListener.static Set<PropertyDescriptor> getDescriptors(Class<?> beanType, com.google.common.base.Predicate<PropertyDescriptor> predicate) Scan the given type and obtainPropertyDescriptorgiven the (optional) predicate (except theclassproperty of any java object).protected static voidgetDescriptors(Class<?> beanType, com.google.common.base.Predicate<PropertyDescriptor> predicate, Map<String, PropertyDescriptor> result, Set<Class<?>> exploredTypes) static MethodgetMutator(Object bean, String property) getReadableProperties(Class<?> beanType) Obtains all readable properties from a given type.protected static voidgetReadableProperties(Class<?> beanType, Set<String> result) protected static voidstatic Class<?> getReadableType(Class<?> beanType, String propertyName) getWriteableProperties(Class<?> beanType) Obtains all writeable properties from a given type.protected static voidgetWriteableProperties(Class<?> beanType, Set<String> result) protected static voidstatic booleanisJavaBeanCompiliant(Class<?> type) Test if the given type is JavaBean compiliant, says that it has two public methods :addPropertyChangeListenerremovePropertyChangeListenerstatic booleanisNestedReadableProperty(Class<?> beanType, String propertyName) Obtains all readable properties from a given type.static voidremovePropertyChangeListener(PropertyChangeListener listener, Object bean) Remove the givenlistenerfrom the givenbeanusing the normalized method namedremovePropertyChangeListener.
-
Field Details
-
ADD_PROPERTY_CHANGE_LISTENER
- See Also:
-
REMOVE_PROPERTY_CHANGE_LISTENER
- See Also:
-
IS_READ_DESCRIPTOR
Is a property is readable ?- Since:
- 2.5.11
-
IS_WRITE_DESCRIPTOR
Is a property is writable ?- Since:
- 2.5.11
-
IS_READ_AND_WRITE_DESCRIPTOR
public static final com.google.common.base.Predicate<PropertyDescriptor> IS_READ_AND_WRITE_DESCRIPTORIs a property is readable and writable ?- Since:
- 2.5.11
-
-
Constructor Details
-
BeanUtil
protected BeanUtil()
-
-
Method Details
-
isJavaBeanCompiliant
Test if the given type is JavaBean compiliant, says that it has two public methods :addPropertyChangeListenerremovePropertyChangeListener
- Parameters:
type- type to test- Returns:
trueif type is Javabean compiliant,falseotherwise- Since:
- 2.0
-
addPropertyChangeListener
public static void addPropertyChangeListener(PropertyChangeListener listener, Object bean) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException Add the givenlistenerto the givenbeanusing the normalized method namedaddPropertyChangeListener.- Parameters:
listener- the listener to addbean- the bean on which the listener is added- Throws:
InvocationTargetException- if could not invoke the methodaddPropertyChangeListenerNoSuchMethodException- if methodaddPropertyChangeListenerdoes not exist on given beanIllegalAccessException- if an illegal access occurs when invoking the methodaddPropertyChangeListener
-
removePropertyChangeListener
public static void removePropertyChangeListener(PropertyChangeListener listener, Object bean) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException Remove the givenlistenerfrom the givenbeanusing the normalized method namedremovePropertyChangeListener.- Parameters:
listener- the listener to removebean- the bean on which the listener is removed- Throws:
InvocationTargetException- if could not invoke the methodremovePropertyChangeListenerNoSuchMethodException- if methodremovePropertyChangeListenerdoes not exist on given beanIllegalAccessException- if an illegal access occurs when invoking the methodremovePropertyChangeListener
-
getReadableProperties
-
getWriteableProperties
-
isNestedReadableProperty
-
getReadableType
-
getDescriptors
public static Set<PropertyDescriptor> getDescriptors(Class<?> beanType, com.google.common.base.Predicate<PropertyDescriptor> predicate) Scan the given type and obtainPropertyDescriptorgiven the (optional) predicate (except theclassproperty of any java object). Note: If no predicate is given, then all descriptors are returned.- Parameters:
beanType- the bean type to scanpredicate- the optional predicate to keep descriptor- Returns:
- set of all matching descriptors
- Since:
- 2.6.11
-
getMutator
-
getDescriptors
protected static void getDescriptors(Class<?> beanType, com.google.common.base.Predicate<PropertyDescriptor> predicate, Map<String, PropertyDescriptor> result, Set<Class<?>> exploredTypes) -
getReadableProperties
-
getReadableProperties
-
getWriteableProperties
-
getWriteableProperties
-