Class BeanMapEntry

java.lang.Object
org.apache.juneau.BeanMapEntry
All Implemented Interfaces:
Map.Entry<String,Object>

public class BeanMapEntry extends Object implements Map.Entry<String,Object>
Represents a single entry in a bean map.

This class can be used to get and set property values on a bean, or to get metadata on a property.

Example:

// Construct a new bean Person person = new Person(); // Wrap it in a bean map BeanMap<Person> beanMap = BeanContext.DEFAULT.toBeanMap(person); // Get a reference to the birthDate property BeanMapEntry birthDate = beanMap.getProperty("birthDate"); // Set the property value birthDate.setValue(new Date(1, 2, 3, 4, 5, 6)); // Or if the DateSwap.DEFAULT_ISO8601DT is registered with the bean context, set a transformed value birthDate.setValue("'1901-03-03T04:05:06-5000'");

See Also:
  • Constructor Details

    • BeanMapEntry

      protected BeanMapEntry(BeanMap<?> beanMap, BeanPropertyMeta property, String pName)
      Constructor.
      Parameters:
      beanMap - The bean map that this entry belongs to.
      property - The bean property.
      pName - The bean property name.
  • Method Details

    • getKey

      public String getKey()
      Specified by:
      getKey in interface Map.Entry<String,Object>
    • getValue

      public Object getValue()
      Returns the value of this property.

      If there is a ObjectSwap associated with this bean property or bean property type class, then this method will return the transformed value. For example, if the bean property type class is a Date and the bean property has the TemporalDateSwap.IsoInstant swap associated with it through the @Swap(value) annotation, this method will return a String containing an ISO8601 date-time string value.

      Specified by:
      getValue in interface Map.Entry<String,Object>
    • setValue

      public Object setValue(Object value)
      Sets the value of this property.

      If the property is an array of type X, then the value can be a Collection<X> or X[] or Object[].

      If the property is a bean type X, then the value can either be an X or a Map.

      If there is a ObjectSwap associated with this bean property or bean property type class, then you must pass in a transformed value. For example, if the bean property type class is a Date and the bean property has the TemporalDateSwap.IsoInstant swap associated with it through the @Swap(value) annotation, the value being passed in must be a String containing an ISO8601 date-time string value.

      Specified by:
      setValue in interface Map.Entry<String,Object>
      Returns:
      The set value after it's been converted.
    • getBeanMap

      public BeanMap<?> getBeanMap()
      Returns the bean map that contains this property.
      Returns:
      The bean map that contains this property.
    • getMeta

      Returns the metadata about this bean property.
      Returns:
      Metadata about this bean property.
    • toString

      public String toString()
      Overrides:
      toString in class Object