Class ArrayValueMap (1.45.2)

public final class ArrayValueMap

Collects the array values of a key/value data object, writing the fields or map values only after all values have been collected.

The typical application for this is when parsing JSON or XML when the value type is known to be an array. It stores the values in a collection during the parsing, and only when the parsing of an object is finished does it convert the collection into an array and stores it.

Use #put(String, Class, Object) when the destination object is a map with string keys and whose values accept an array of objects. Use #put(Field, Class, Object) when setting the value of a field using reflection, assuming its type accepts an array of objects. One can potentially use both put methods for example on an instance of GenericData.

Implementation is not thread-safe. For a thread-safe choice instead use an implementation of ConcurrentMap.

Inheritance

Object > ArrayValueMap

Constructors

ArrayValueMap(Object destination)

public ArrayValueMap(Object destination)
Parameter
Name Description
destination Object

destination object whose fields must be set, or destination map whose values must be set

Methods

put(String keyName, Class<?> arrayComponentType, Object value)

public void put(String keyName, Class<?> arrayComponentType, Object value)

Puts an additional value for the given key name, accumulating values on repeated calls on the same key name.

Parameters
Name Description
keyName String

key name

arrayComponentType Class<?>

array component type

value Object

value

put(Field field, Class<?> arrayComponentType, Object value)

public void put(Field field, Class<?> arrayComponentType, Object value)

Puts an additional value for the given field, accumulating values on repeated calls on the same field.

Parameters
Name Description
field Field

field

arrayComponentType Class<?>

array component type

value Object

value

setValues()

public void setValues()

Sets the fields of the given object using the values collected during parsing of the object's fields.