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 BeanSupport INSTANCE  
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected BeanSupport()
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    void addPropertyName​(java.lang.Class<?> beanClass, java.lang.String propertyName, java.lang.String propertyEventName)
    Adds the mapping for the specified property.
    protected void collectForbiddenCopies​(java.util.Set<java.lang.String> rc, java.lang.Class<?> clazz)
    Collects the NoCopy properties (self-recursive).
    protected void collectTransientProperties​(java.util.List<java.lang.String> rc, java.lang.Class<?> clazz)
    Collects the non-transient properties (self-recursive).
    void firePropertyEvents​(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.
    boolean isCopyForbidden​(java.lang.Class<?> beanClass, java.lang.String propertyName)
    Returns whether the given property is forbidden to be copied.
    boolean isTransient​(java.lang.Object bean, java.lang.String propertyName)
    Returns true when the given property is transient.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • 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 occurs
      propertyName - the name of the bean property
      propertyEventName - 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 - listeners
      bean - 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 as NoCopy or is isTransient(Object, String).
      Parameters:
      beanClass - the bean class
      propertyName - the name of the property
      Returns:
      true when IBean.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 class
      create - 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 the NoCopy properties (self-recursive).
      Parameters:
      rc - collection where properties need to be collected
      clazz - 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 of LangUtils.isTransient(PropertyDescriptor).
      Parameters:
      bean - Bean or class of bean
      propertyName - 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 collected
      clazz - class to be inspected
      See Also:
      isTransient(Object, String)