Class BeanMap

  • All Implemented Interfaces:
    Cloneable, Map

    @Deprecated(since="2021-04-30")
    public class BeanMap
    extends AbstractMap
    implements Cloneable
    Deprecated.
    Identical class now available in commons-beanutils (full jar version). This version is due to be removed in collections v4.0.
    An implementation of Map for JavaBeans which uses introspection to get and put properties in the bean.

    If an exception occurs during attempts to get or set a property then the property is considered non existent in the Map

    Since:
    Commons Collections 1.0
    • Field Detail

      • NULL_ARGUMENTS

        public static final Object[] NULL_ARGUMENTS
        Deprecated.
        An empty array. Used to invoke accessors via reflection.
      • defaultTransformers

        public static HashMap defaultTransformers
        Deprecated.
        Maps primitive Class types to transformers. The transformer transform strings into the appropriate primitive wrapper.
    • Constructor Detail

      • BeanMap

        public BeanMap()
        Deprecated.
        Constructs a new empty BeanMap.
      • BeanMap

        public BeanMap​(Object bean)
        Deprecated.
        Constructs a new BeanMap that operates on the specified bean. If the given bean is null, then this map will be empty.
        Parameters:
        bean - the bean for this map to operate on
    • Method Detail

      • clone

        public Object clone()
                     throws CloneNotSupportedException
        Deprecated.
        Clone this bean map using the following process:
        • If there is no underlying bean, return a cloned BeanMap without a bean.
        • Since there is an underlying bean, try to instantiate a new bean of the same type using Class.newInstance().
        • If the instantiation fails, throw a CloneNotSupportedException
        • Clone the bean map and set the newly instantiated bean as the underlying bean for the bean map.
        • Copy each property that is both readable and writable from the existing object to a cloned bean map.
        • If anything fails along the way, throw a CloneNotSupportedException.
          Throws:
          CloneNotSupportedException
        • putAllWriteable

          public void putAllWriteable​(BeanMap map)
          Deprecated.
          Puts all of the writable properties from the given BeanMap into this BeanMap. Read-only and Write-only properties will be ignored.
          Parameters:
          map - the BeanMap whose properties to put
        • clear

          public void clear()
          Deprecated.
          This method reinitializes the bean map to have default values for the bean's properties. This is accomplished by constructing a new instance of the bean which the map uses as its underlying data source. This behavior for clear() differs from the Map contract in that the mappings are not actually removed from the map (the mappings for a BeanMap are fixed).
          Specified by:
          clear in interface Map
          Overrides:
          clear in class AbstractMap
        • containsKey

          public boolean containsKey​(Object name)
          Deprecated.
          Returns true if the bean defines a property with the given name.

          The given name must be a String; if not, this method returns false. This method will also return false if the bean does not define a property with that name.

          Write-only properties will not be matched as the test operates against property read methods.

          Specified by:
          containsKey in interface Map
          Overrides:
          containsKey in class AbstractMap
          Parameters:
          name - the name of the property to check
          Returns:
          false if the given name is null or is not a String; false if the bean does not define a property with that name; or true if the bean does define a property with that name
        • containsValue

          public boolean containsValue​(Object value)
          Deprecated.
          Returns true if the bean defines a property whose current value is the given object.
          Specified by:
          containsValue in interface Map
          Overrides:
          containsValue in class AbstractMap
          Parameters:
          value - the value to check
          Returns:
          false true if the bean has at least one property whose current value is that object, false otherwise
        • get

          public Object get​(Object name)
          Deprecated.
          Returns the value of the bean's property with the given name.

          The given name must be a String and must not be null; otherwise, this method returns null. If the bean defines a property with the given name, the value of that property is returned. Otherwise, null is returned.

          Write-only properties will not be matched as the test operates against property read methods.

          Specified by:
          get in interface Map
          Overrides:
          get in class AbstractMap
          Parameters:
          name - the name of the property whose value to return
          Returns:
          the value of the property with that name
        • size

          public int size()
          Deprecated.
          Returns the number of properties defined by the bean.
          Specified by:
          size in interface Map
          Overrides:
          size in class AbstractMap
          Returns:
          the number of properties defined by the bean
        • keySet

          public Set keySet()
          Deprecated.
          Get the keys for this BeanMap.

          Write-only properties are not included in the returned set of property names, although it is possible to set their value and to get their type.

          Specified by:
          keySet in interface Map
          Overrides:
          keySet in class AbstractMap
          Returns:
          BeanMap keys. The Set returned by this method is not modifiable.
        • entrySet

          public Set entrySet()
          Deprecated.
          Gets a Set of MapEntry objects that are the mappings for this BeanMap.

          Each MapEntry can be set but not removed.

          Specified by:
          entrySet in interface Map
          Specified by:
          entrySet in class AbstractMap
          Returns:
          the unmodifiable set of mappings
        • values

          public Collection values()
          Deprecated.
          Returns the values for the BeanMap.
          Specified by:
          values in interface Map
          Overrides:
          values in class AbstractMap
          Returns:
          values for the BeanMap. The returned collection is not modifiable.
        • getType

          public Class getType​(String name)
          Deprecated.
          Returns the type of the property with the given name.
          Parameters:
          name - the name of the property
          Returns:
          the type of the property, or null if no such property exists
        • keyIterator

          public Iterator keyIterator()
          Deprecated.
          Convenience method for getting an iterator over the keys.

          Write-only properties will not be returned in the iterator.

          Returns:
          an iterator over the keys
        • valueIterator

          public Iterator valueIterator()
          Deprecated.
          Convenience method for getting an iterator over the values.
          Returns:
          an iterator over the values
        • entryIterator

          public Iterator entryIterator()
          Deprecated.
          Convenience method for getting an iterator over the entries.
          Returns:
          an iterator over the entries
        • getBean

          public Object getBean()
          Deprecated.
          Returns the bean currently being operated on. The return value may be null if this map is empty.
          Returns:
          the bean being operated on by this map
        • setBean

          public void setBean​(Object newBean)
          Deprecated.
          Sets the bean to be operated on by this map. The given value may be null, in which case this map will be empty.
          Parameters:
          newBean - the new bean to operate on
        • getReadMethod

          public Method getReadMethod​(String name)
          Deprecated.
          Returns the accessor for the property with the given name.
          Parameters:
          name - the name of the property
          Returns:
          the accessor method for the property, or null
        • getWriteMethod

          public Method getWriteMethod​(String name)
          Deprecated.
          Returns the mutator for the property with the given name.
          Parameters:
          name - the name of the property
          Returns:
          the mutator method for the property, or null