Package org.apache.sling.api.wrappers
Class ValueMapUtil
java.lang.Object
org.apache.sling.api.wrappers.ValueMapUtil
Factory methods to create
ValueMaps.- Since:
- 2.7
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull ValueMapDecorates the givenValueMapwith a caching layer.static @NotNull ValueMapMerge providedValueMapsinto a single viewValueMapthat aggregates all key-value pairs of the given maps.static @NotNull ValueMapA convenience method that turns the var-args into aCollectionand delegates tomerge(List).static @NotNull ValueMapmergeAndCache(@NotNull List<ValueMap> valueMaps) Convenience method that allows creating a mergedValueMapwhere accessed mappings are cached to optimize repeated lookups.
-
Method Details
-
merge
A convenience method that turns the var-args into aCollectionand delegates tomerge(List).- Parameters:
valueMaps- theValueMapinstances to merge- Returns:
- the merged
ValueMapview - See Also:
-
merge
Merge providedValueMapsinto a single viewValueMapthat 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.
E.g. assumingmerge(vm1, vm2, vm3where all mapsvm1, vm2, vm3have a value mapped to the keyk1, then the value fromvm1is returned.- Parameters:
valueMaps- theValueMapinstances to merge- Returns:
- the merged
ValueMapview
-
mergeAndCache
Convenience method that allows creating a mergedValueMapwhere accessed mappings are cached to optimize repeated lookups.
This is equivalent to callingcache(merge(valueMaps)).- Parameters:
valueMaps- theValueMapinstances to merge- Returns:
- the merged and cached
ValueMapview
-
cache
Decorates the givenValueMapwith a caching layer. Every key-value pair that is accessed is cached for subsequent accesses. Calls toValueMap#keySet(),ValueMap#values()andValueMap#entrySet()will cause all entries to be cached.
Note: if the underlyingValueMapis modified, the modification may not be reflected via the caching wrapper.- Parameters:
valueMap- theValueMapinstance to cache- Returns:
- the cached
ValueMapview
-