Class MultiWrapDynaBean

java.lang.Object
org.apache.commons.configuration2.builder.combined.MultiWrapDynaBean
All Implemented Interfaces:
org.apache.commons.beanutils.DynaBean

class MultiWrapDynaBean extends Object implements org.apache.commons.beanutils.DynaBean

An implementation of the DynaBean interfaces which wraps multiple other beans.

An instance of this class is constructed with a collection of beans to be wrapped. When reading or writing a property the wrapped bean which defines this property is determined, and the operation is executed on this bean.

The wrapped beans should have disjunct properties. Otherwise, it is undefined which bean property is read or written.

Since:
2.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final org.apache.commons.beanutils.DynaClass
    Stores the class of this DynaBean.
    private final Map<String,org.apache.commons.beanutils.DynaBean>
    A map which associates property names with their defining beans.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of MultiWrapDynaBean and initializes it with the given collections of beans to be wrapped.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(String name, String key)
    This operation is not supported by the WrapDynaBean objects used internally by this class.
    private static org.apache.commons.beanutils.DynaBean
    Creates a DynaBean object for the given bean.
    private org.apache.commons.beanutils.DynaBean
    fetchBean(String property)
    Returns the bean instance to which the given property belongs.
    get(String name)
     
    get(String name, int index)
     
    get(String name, String key)
     
    org.apache.commons.beanutils.DynaClass
    This implementation returns an instance of MultiWrapDynaClass.
    void
    remove(String name, String key)
    This operation is not supported by the WrapDynaBean objects used internally by this class.
    void
    set(String name, int index, Object value)
     
    void
    set(String name, Object value)
     
    void
    set(String name, String key, Object value)
     

    Methods inherited from class java.lang.Object

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

    • dynaClass

      private final org.apache.commons.beanutils.DynaClass dynaClass
      Stores the class of this DynaBean.
    • propsToBeans

      private final Map<String,org.apache.commons.beanutils.DynaBean> propsToBeans
      A map which associates property names with their defining beans.
  • Constructor Details

    • MultiWrapDynaBean

      public MultiWrapDynaBean(Collection<?> beans)
      Creates a new instance of MultiWrapDynaBean and initializes it with the given collections of beans to be wrapped.
      Parameters:
      beans - the wrapped beans
  • Method Details

    • contains

      public boolean contains(String name, String key)
      This operation is not supported by the WrapDynaBean objects used internally by this class. Therefore, just an exception is thrown.
      Specified by:
      contains in interface org.apache.commons.beanutils.DynaBean
    • get

      public Object get(String name)
      Specified by:
      get in interface org.apache.commons.beanutils.DynaBean
    • get

      public Object get(String name, int index)
      Specified by:
      get in interface org.apache.commons.beanutils.DynaBean
    • get

      public Object get(String name, String key)
      Specified by:
      get in interface org.apache.commons.beanutils.DynaBean
    • getDynaClass

      public org.apache.commons.beanutils.DynaClass getDynaClass()
      This implementation returns an instance of MultiWrapDynaClass.
      Specified by:
      getDynaClass in interface org.apache.commons.beanutils.DynaBean
    • remove

      public void remove(String name, String key)
      This operation is not supported by the WrapDynaBean objects used internally by this class. Therefore, just an exception is thrown.
      Specified by:
      remove in interface org.apache.commons.beanutils.DynaBean
    • set

      public void set(String name, Object value)
      Specified by:
      set in interface org.apache.commons.beanutils.DynaBean
    • set

      public void set(String name, int index, Object value)
      Specified by:
      set in interface org.apache.commons.beanutils.DynaBean
    • set

      public void set(String name, String key, Object value)
      Specified by:
      set in interface org.apache.commons.beanutils.DynaBean
    • fetchBean

      private org.apache.commons.beanutils.DynaBean fetchBean(String property)
      Returns the bean instance to which the given property belongs. If no such bean is found, an arbitrary bean is returned. (This causes the operation on this bean to fail with a meaningful error message.)
      Parameters:
      property - the property name
      Returns:
      the bean defining this property
    • createDynaBean

      private static org.apache.commons.beanutils.DynaBean createDynaBean(Object bean)
      Creates a DynaBean object for the given bean.
      Parameters:
      bean - the bean
      Returns:
      the DynaBean for this bean