org.springframework.beans

Class MutablePropertyValues

  • java.lang.Object
    • org.springframework.beans.MutablePropertyValues
  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<PropertyValue>, PropertyValues
    Direct Known Subclasses:
    ServletRequestParameterPropertyValues


    public class MutablePropertyValues
    extends java.lang.Object
    implements PropertyValues, java.io.Serializable
    The default implementation of the PropertyValues interface. Allows simple manipulation of properties, and provides constructors to support deep copy and construction from a Map.
    Since:
    13 May 2001
    Author:
    Rod Johnson, Juergen Hoeller, Rob Harrop
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      MutablePropertyValues add(java.lang.String propertyName, java.lang.Object propertyValue)
      Add a PropertyValue object, replacing any existing one for the corresponding property or getting merged with it (if applicable).
      MutablePropertyValues addPropertyValue(PropertyValue pv)
      Add a PropertyValue object, replacing any existing one for the corresponding property or getting merged with it (if applicable).
      void addPropertyValue(java.lang.String propertyName, java.lang.Object propertyValue)
      Overloaded version of addPropertyValue that takes a property name and a property value.
      MutablePropertyValues addPropertyValues(java.util.Map<?,?> other)
      Add all property values from the given Map.
      MutablePropertyValues addPropertyValues(PropertyValues other)
      Copy all given PropertyValues into this object.
      PropertyValues changesSince(PropertyValues old)
      Return the changes since the previous PropertyValues.
      void clearProcessedProperty(java.lang.String propertyName)
      Clear the "processed" registration of the given property, if any.
      boolean contains(java.lang.String propertyName)
      Is there a property value (or other processing entry) for this property?
      boolean equals(java.lang.Object other) 
      java.lang.Object get(java.lang.String propertyName)
      Get the raw property value, if any.
      PropertyValue getPropertyValue(java.lang.String propertyName)
      Return the property value with the given name, if any.
      java.util.List<PropertyValue> getPropertyValueList()
      Return the underlying List of PropertyValue objects in its raw form.
      PropertyValue[] getPropertyValues()
      Return an array of the PropertyValue objects held in this object.
      int hashCode() 
      boolean isConverted()
      Return whether this holder contains converted values only (true), or whether the values still need to be converted (false).
      boolean isEmpty()
      Does this holder not contain any PropertyValue objects at all?
      java.util.Iterator<PropertyValue> iterator()
      Return an Iterator over the property values.
      void registerProcessedProperty(java.lang.String propertyName)
      Register the specified property as "processed" in the sense of some processor calling the corresponding setter method outside of the PropertyValue(s) mechanism.
      void removePropertyValue(PropertyValue pv)
      Remove the given PropertyValue, if contained.
      void removePropertyValue(java.lang.String propertyName)
      Overloaded version of removePropertyValue that takes a property name.
      void setConverted()
      Mark this holder as containing converted values only (i.e.
      void setPropertyValueAt(PropertyValue pv, int i)
      Modify a PropertyValue object held in this object.
      int size()
      Return the number of PropertyValue entries in the list.
      java.util.Spliterator<PropertyValue> spliterator()
      Return a Spliterator over the property values.
      java.util.stream.Stream<PropertyValue> stream()
      Return a sequential Stream containing the property values.
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Constructor Detail

      • MutablePropertyValues

        public MutablePropertyValues()
        Creates a new empty MutablePropertyValues object.

        Property values can be added with the add method.

        See Also:
        add(String, Object)
      • MutablePropertyValues

        public MutablePropertyValues(@Nullable
                                     PropertyValues original)
        Deep copy constructor. Guarantees PropertyValue references are independent, although it can't deep copy objects currently referenced by individual PropertyValue objects.
        Parameters:
        original - the PropertyValues to copy
        See Also:
        addPropertyValues(PropertyValues)
      • MutablePropertyValues

        public MutablePropertyValues(@Nullable
                                     java.util.Map<?,?> original)
        Construct a new MutablePropertyValues object from a Map.
        Parameters:
        original - a Map with property values keyed by property name Strings
        See Also:
        addPropertyValues(Map)
      • MutablePropertyValues

        public MutablePropertyValues(@Nullable
                                     java.util.List<PropertyValue> propertyValueList)
        Construct a new MutablePropertyValues object using the given List of PropertyValue objects as-is.

        This is a constructor for advanced usage scenarios. It is not intended for typical programmatic use.

        Parameters:
        propertyValueList - a List of PropertyValue objects
    • Method Detail

      • getPropertyValueList

        public java.util.List<PropertyValue> getPropertyValueList()
        Return the underlying List of PropertyValue objects in its raw form. The returned List can be modified directly, although this is not recommended.

        This is an accessor for optimized access to all PropertyValue objects. It is not intended for typical programmatic use.

      • size

        public int size()
        Return the number of PropertyValue entries in the list.
      • addPropertyValues

        public MutablePropertyValues addPropertyValues(@Nullable
                                                       PropertyValues other)
        Copy all given PropertyValues into this object. Guarantees PropertyValue references are independent, although it can't deep copy objects currently referenced by individual PropertyValue objects.
        Parameters:
        other - the PropertyValues to copy
        Returns:
        this in order to allow for adding multiple property values in a chain
      • addPropertyValues

        public MutablePropertyValues addPropertyValues(@Nullable
                                                       java.util.Map<?,?> other)
        Add all property values from the given Map.
        Parameters:
        other - a Map with property values keyed by property name, which must be a String
        Returns:
        this in order to allow for adding multiple property values in a chain
      • addPropertyValue

        public MutablePropertyValues addPropertyValue(PropertyValue pv)
        Add a PropertyValue object, replacing any existing one for the corresponding property or getting merged with it (if applicable).
        Parameters:
        pv - the PropertyValue object to add
        Returns:
        this in order to allow for adding multiple property values in a chain
      • addPropertyValue

        public void addPropertyValue(java.lang.String propertyName,
                                     java.lang.Object propertyValue)
        Overloaded version of addPropertyValue that takes a property name and a property value.

        Note: As of Spring 3.0, we recommend using the more concise and chaining-capable variant add(java.lang.String, java.lang.Object).

        Parameters:
        propertyName - name of the property
        propertyValue - value of the property
        See Also:
        addPropertyValue(PropertyValue)
      • add

        public MutablePropertyValues add(java.lang.String propertyName,
                                         @Nullable
                                         java.lang.Object propertyValue)
        Add a PropertyValue object, replacing any existing one for the corresponding property or getting merged with it (if applicable).
        Parameters:
        propertyName - name of the property
        propertyValue - value of the property
        Returns:
        this in order to allow for adding multiple property values in a chain
      • setPropertyValueAt

        public void setPropertyValueAt(PropertyValue pv,
                                       int i)
        Modify a PropertyValue object held in this object. Indexed from 0.
      • removePropertyValue

        public void removePropertyValue(PropertyValue pv)
        Remove the given PropertyValue, if contained.
        Parameters:
        pv - the PropertyValue to remove
      • removePropertyValue

        public void removePropertyValue(java.lang.String propertyName)
        Overloaded version of removePropertyValue that takes a property name.
        Parameters:
        propertyName - name of the property
        See Also:
        removePropertyValue(PropertyValue)
      • getPropertyValue

        @Nullable
        public PropertyValue getPropertyValue(java.lang.String propertyName)
        Description copied from interface: PropertyValues
        Return the property value with the given name, if any.
        Specified by:
        getPropertyValue in interface PropertyValues
        Parameters:
        propertyName - the name to search for
        Returns:
        the property value, or null if none
      • get

        @Nullable
        public java.lang.Object get(java.lang.String propertyName)
        Get the raw property value, if any.
        Parameters:
        propertyName - the name to search for
        Returns:
        the raw property value, or null if none found
        Since:
        4.0
        See Also:
        getPropertyValue(String), PropertyValue.getValue()
      • changesSince

        public PropertyValues changesSince(PropertyValues old)
        Description copied from interface: PropertyValues
        Return the changes since the previous PropertyValues. Subclasses should also override equals.
        Specified by:
        changesSince in interface PropertyValues
        Parameters:
        old - old property values
        Returns:
        the updated or new properties. Return empty PropertyValues if there are no changes.
        See Also:
        Object.equals(java.lang.Object)
      • contains

        public boolean contains(java.lang.String propertyName)
        Description copied from interface: PropertyValues
        Is there a property value (or other processing entry) for this property?
        Specified by:
        contains in interface PropertyValues
        Parameters:
        propertyName - the name of the property we're interested in
        Returns:
        whether there is a property value for this property
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: PropertyValues
        Does this holder not contain any PropertyValue objects at all?
        Specified by:
        isEmpty in interface PropertyValues
      • registerProcessedProperty

        public void registerProcessedProperty(java.lang.String propertyName)
        Register the specified property as "processed" in the sense of some processor calling the corresponding setter method outside of the PropertyValue(s) mechanism.

        This will lead to true being returned from a contains(java.lang.String) call for the specified property.

        Parameters:
        propertyName - the name of the property.
      • clearProcessedProperty

        public void clearProcessedProperty(java.lang.String propertyName)
        Clear the "processed" registration of the given property, if any.
        Since:
        3.2.13
      • setConverted

        public void setConverted()
        Mark this holder as containing converted values only (i.e. no runtime resolution needed anymore).
      • isConverted

        public boolean isConverted()
        Return whether this holder contains converted values only (true), or whether the values still need to be converted (false).
      • equals

        public boolean equals(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object