Class DelegateBeanMap<T>
- Type Parameters:
T- The class type of the wrapped bean.
BeanMap where property values can be overridden, removed, or reordered without
affecting the underlying bean.
Provides the filterKeys(List) method for specifying the keys to keep in the bean map and in what order
they should appear.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Field Summary
Fields inherited from class org.apache.juneau.commons.bean.BeanMap
arrayPropertyCache, bean, meta, propertyCache -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a key in the next position.entrySet()Returns all the properties associated with the bean.booleanCompares the specified object with this map for equality.filterKeys(List<String> keys) Remove all but the specified properties from this bean map.forEachProperty(Predicate<BeanPropertyMeta> filter, Consumer<BeanPropertyMeta> action) Performs an action on each property in this bean map.Gets a property on the bean.Returns a simple collection of properties for this bean map.inthashCode()Returns the hash code value for this map.keySet()Returns the names of all properties associated with the bean.Sets a property on the bean.Methods inherited from class org.apache.juneau.commons.bean.BeanMap
add, containsKey, forEachValue, get, getBean, getBean, getBeanInfo, getBeanSession, getMeta, getMissingRequiredProperties, getProperties, getProperty, getPropertyMeta, getRaw, isInActiveView, load, of, of, resolveVars, setBeanSessionMethods inherited from class java.util.AbstractMap
clear, clone, containsValue, isEmpty, putAll, size, toString, valuesMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
DelegateBeanMap
Constructor.- Parameters:
bean- The bean being wrapped.session- The bean session that created this bean map.
-
-
Method Details
-
addKey
Add a key in the next position.- Parameters:
key- The key to add.
-
entrySet
Description copied from class:BeanMapReturns all the properties associated with the bean. -
filterKeys
Remove all but the specified properties from this bean map.This does not affect the underlying bean.
- Parameters:
keys- The remaining keys in the bean map (in the specified order).- Returns:
- This object.
-
forEachProperty
public BeanMap<T> forEachProperty(Predicate<BeanPropertyMeta> filter, Consumer<BeanPropertyMeta> action) Description copied from class:BeanMapPerforms an action on each property in this bean map.If a
BeanSessionis attached and has an active view, only properties that are visible under that view (as determined byBeanSession.isPropertyInActiveView(BeanPropertyMeta)) are visited.- Overrides:
forEachPropertyin classBeanMap<T>- Parameters:
filter- The filter to apply to properties.action- The action.- Returns:
- This object.
-
get
Description copied from class:BeanMapGets a property on the bean.If an
ObjectSwap-style transform is 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 aDateand the bean property has theDateFormat.ISO_INSTANTsetting associated with it through the@Swap(value)annotation, this method will return a String containing an ISO8601 date-time string value.Example:
// Construct a bean with a 'birthDate' Date field Personperson =new Person();person .setBirthDate(new Date(1, 2, 3, 4, 5, 6));// Create a marshalling context and add the ISO8601 date-time swap MarshallingContextmarshallingContext = MarshallingContext.create ().dateFormat(DateFormat.ISO_INSTANT ).build();// Wrap our bean in a bean map BeanMap<Person>beanMap =marshallingContext .toBeanMap(person );// Get the field as a string (i.e. "'1901-03-03T04:05:06-5000'") StringbirthDate =beanMap .get("birthDate" ); -
getProperties
Description copied from class:BeanMapReturns a simple collection of properties for this bean map.- Overrides:
getPropertiesin classBeanMap<T>- Returns:
- A simple collection of properties for this bean map.
-
keySet
Description copied from class:BeanMapReturns the names of all properties associated with the bean.The returned set is unmodifiable.
-
put
Description copied from class:BeanMapSets a property on the bean.If there is a
ObjectSwapassociated 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 aDateand the bean property has theDateFormat.ISO_INSTANTsetting associated with it through the@Swap(value)annotation, the value being passed in must be a String containing an ISO8601 date-time string value.Example:
// Construct a bean with a 'birthDate' Date field Personperson =new Person();// Create a marshalling context and add the ISO8601 date-time swap MarshallingContextmarshallingContext = MarshallingContext.create ().dateFormat(DateFormat.ISO_INSTANT ).build();// Wrap our bean in a bean map BeanMap<Person>beanMap =marshallingContext .toBeanMap(person );// Set the field beanMap .put("birthDate" ,"'1901-03-03T04:05:06-5000'" );- Specified by:
putin interfaceMap<String,Object> - Overrides:
putin classBeanMap<T>- Parameters:
key- The name of the property to set.val- The value to set the property to. Can benull to set the property tonull .- Returns:
- If the
beanMapPutReturnsOldValuesetting istrue on the session's bean configuration, then the old value of the property is returned. Otherwise, this method always returnsnull .
-
equals
Description copied from class:BeanMapCompares the specified object with this map for equality.Returns
true if the given object is also a map and the two maps represent the same mappings. More formally, two mapsm1 andm2 represent the same mappings ifm1.entrySet().equals(m2.entrySet()) .This implementation compares the entry sets of the two maps.
-
hashCode
Description copied from class:BeanMapReturns the hash code value for this map.The hash code of a map is defined to be the sum of the hash codes of each entry in the map's
entrySet() view. This ensures thatm1.equals(m2) implies thatm1.hashCode()==m2.hashCode() for any two mapsm1 andm2 , as required by the general contract ofObject.hashCode().This implementation computes the hash code from the entry set.
-
remove
-