Package rs.baselib.bean
Class BeanSupport
java.lang.Object
rs.baselib.bean.BeanSupport
public class BeanSupport
extends java.lang.Object
Support Bean property actions.
- Author:
- ralph
-
Field Summary
Fields Modifier and Type Field Description static BeanSupportINSTANCE -
Constructor Summary
Constructors Modifier Constructor Description protectedBeanSupport()Constructor. -
Method Summary
Modifier and Type Method Description voidaddPropertyName(java.lang.Class<?> beanClass, java.lang.String propertyName, java.lang.String propertyEventName)Adds the mapping for the specified property.protected voidcollectForbiddenCopies(java.util.Set<java.lang.String> rc, java.lang.Class<?> clazz)Collects theNoCopyproperties (self-recursive).protected voidcollectTransientProperties(java.util.List<java.lang.String> rc, java.lang.Class<?> clazz)Collects the non-transient properties (self-recursive).voidfirePropertyEvents(java.util.Collection<java.beans.PropertyChangeListener> listeners, java.lang.Object bean)Fires property change events to the listeners for the given bean.protected java.util.Set<java.lang.String>getForbiddenList(java.lang.Class<?> beanClass, boolean create)Returns the set of property names forbidden to be copied.java.util.List<java.lang.String>getNonTransientProperties(java.lang.Object bean)Returns the non-transient properties of the bean or class.java.util.Map<java.lang.String,java.lang.String>getPropertyMap(java.lang.Class<?> beanClass)Returns the map for the bean class.java.util.List<java.lang.String>getTransientProperties(java.lang.Object bean)Returns the transient properties of the bean or class.booleanisCopyForbidden(java.lang.Class<?> beanClass, java.lang.String propertyName)Returns whether the given property is forbidden to be copied.booleanisTransient(java.lang.Object bean, java.lang.String propertyName)Returns true when the given property is transient.
-
Field Details
-
Constructor Details
-
BeanSupport
protected BeanSupport()Constructor.
-
-
Method Details
-
addPropertyName
public void addPropertyName(java.lang.Class<?> beanClass, java.lang.String propertyName, java.lang.String propertyEventName)Adds the mapping for the specified property.- Parameters:
beanClass- the class where the property occurspropertyName- the name of the bean propertypropertyEventName- the name to appear in change events
-
getPropertyMap
public java.util.Map<java.lang.String,java.lang.String> getPropertyMap(java.lang.Class<?> beanClass)Returns the map for the bean class. This method will always create a map if not already present.- Parameters:
beanClass- the class of the bean- Returns:
- the property map.
-
firePropertyEvents
public void firePropertyEvents(java.util.Collection<java.beans.PropertyChangeListener> listeners, java.lang.Object bean)Fires property change events to the listeners for the given bean.- Parameters:
listeners- listenersbean- bean
-
isCopyForbidden
public boolean isCopyForbidden(java.lang.Class<?> beanClass, java.lang.String propertyName)Returns whether the given property is forbidden to be copied. The property was either marked asNoCopyor isisTransient(Object, String).- Parameters:
beanClass- the bean classpropertyName- the name of the property- Returns:
truewhenIBean.copyTo(Object)must not copy this property
-
getForbiddenList
protected java.util.Set<java.lang.String> getForbiddenList(java.lang.Class<?> beanClass, boolean create)Returns the set of property names forbidden to be copied.- Parameters:
beanClass- the classcreate- whether the list shall be created if it doesn't exist yet- Returns:
- the set of forbidden properties
-
collectForbiddenCopies
protected void collectForbiddenCopies(java.util.Set<java.lang.String> rc, java.lang.Class<?> clazz)Collects theNoCopyproperties (self-recursive).- Parameters:
rc- collection where properties need to be collectedclazz- class to be inspected- See Also:
LangUtils.isNoCopy(PropertyDescriptor)
-
isTransient
public boolean isTransient(java.lang.Object bean, java.lang.String propertyName)Returns true when the given property is transient. The method is a cached version ofLangUtils.isTransient(PropertyDescriptor).- Parameters:
bean- Bean or class of beanpropertyName- name of property- Returns:
- true when property is transient
-
getTransientProperties
public java.util.List<java.lang.String> getTransientProperties(java.lang.Object bean)Returns the transient properties of the bean or class.- Parameters:
bean- bean or class of bean- Returns:
- list of non-transient properties
- See Also:
isTransient(Object, String)
-
getNonTransientProperties
public java.util.List<java.lang.String> getNonTransientProperties(java.lang.Object bean)Returns the non-transient properties of the bean or class.- Parameters:
bean- bean or class of bean- Returns:
- list of non-transient properties
- See Also:
isTransient(Object, String)
-
collectTransientProperties
protected void collectTransientProperties(java.util.List<java.lang.String> rc, java.lang.Class<?> clazz)Collects the non-transient properties (self-recursive).- Parameters:
rc- collection where properties need to be collectedclazz- class to be inspected- See Also:
isTransient(Object, String)
-