Class MergingValueMap
- java.lang.Object
-
- org.apache.sling.api.wrappers.impl.MergingValueMap
-
public class MergingValueMap extends Object implements ValueMap
Merge providedValueMaps
into a single viewValueMap
that aggregates all key-value pairs of the given maps. The value for a key-value pair is taken from the firstValueMap
(in iteration order) that has a mapping for the given key.
In case you would like to avoid duplicating properties on multiple resources, you can use a
to get a concatenated map of properties.MergingValueMap
-
-
Constructor Summary
Constructors Constructor Description MergingValueMap(@NotNull List<ValueMap> valueMaps)
Constructor that allows merging any number ofValueMap
instances into a singleValueMap
view.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
@NotNull Set<Map.Entry<String,Object>>
entrySet()
Object
get(Object key)
boolean
isEmpty()
@NotNull Set<String>
keySet()
Object
put(String aKey, Object value)
void
putAll(Map<? extends String,?> properties)
Object
remove(Object key)
int
size()
@NotNull Collection<Object>
values()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Constructor Detail
-
MergingValueMap
public MergingValueMap(@NotNull @NotNull List<ValueMap> valueMaps)
Constructor that allows merging any number ofValueMap
instances into a singleValueMap
view. The keys of the view are the union of the keys of all value maps. The values of the view is the mapping of all keys to their respective value. The entries are the key-value pairs. Values are retrieved by getting the value for a key for eachValueMap
until a non-null value is found.- Parameters:
valueMaps
- The ValueMaps to be merged.- See Also:
ValueMapUtil.merge(List)
,ValueMapUtil.merge(ValueMap...)
-
-
Method Detail
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<String,Object>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<String,Object>
-
values
@NotNull public @NotNull Collection<Object> values()
-
-