public final class ImmutableValueMap extends Object implements org.apache.sling.api.resource.ValueMap
ValueMap that does not support changing its content.
All methods that may change the content will throw a UnsupportedOperationException.
Static convenience methods provide similar behavior as Guava ImmutableMap variants.| Modifier and Type | Class and Description |
|---|---|
static class |
ImmutableValueMap.Builder
Builder interface for
ImmutableValueMap. |
| Modifier and Type | Method and Description |
|---|---|
static ImmutableValueMap.Builder |
builder()
Returns a new builder.
|
void |
clear()
Deprecated.
Unsupported operation
|
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
static ImmutableValueMap |
copyOf(Map<String,Object> map)
Returns an immutable map containing the same entries as
map. |
Set<Map.Entry<String,Object>> |
entrySet() |
Object |
get(Object key) |
<T> T |
get(String name,
Class<T> type) |
<T> T |
get(String name,
T defaultValue) |
boolean |
isEmpty() |
Set<String> |
keySet() |
static ImmutableValueMap |
of()
Returns the empty map.
|
static ImmutableValueMap |
of(String k1,
Object v1)
Returns an immutable map containing a single entry.
|
static ImmutableValueMap |
of(String k1,
Object v1,
String k2,
Object v2)
Returns an immutable map containing the given entries, in order.
|
static ImmutableValueMap |
of(String k1,
Object v1,
String k2,
Object v2,
String k3,
Object v3)
Returns an immutable map containing the given entries, in order.
|
static ImmutableValueMap |
of(String k1,
Object v1,
String k2,
Object v2,
String k3,
Object v3,
String k4,
Object v4)
Returns an immutable map containing the given entries, in order.
|
static ImmutableValueMap |
of(String k1,
Object v1,
String k2,
Object v2,
String k3,
Object v3,
String k4,
Object v4,
String k5,
Object v5)
Returns an immutable map containing the given entries, in order.
|
Object |
put(String key,
Object value)
Deprecated.
Unsupported operation
|
void |
putAll(Map<? extends String,? extends Object> m)
Deprecated.
Unsupported operation
|
Object |
remove(Object key)
Deprecated.
Unsupported operation
|
int |
size() |
Collection<Object> |
values() |
public <T> T get(String name, Class<T> type)
get in interface org.apache.sling.api.resource.ValueMappublic <T> T get(String name, T defaultValue)
get in interface org.apache.sling.api.resource.ValueMappublic boolean containsKey(Object key)
containsKey in interface Map<String,Object>public boolean containsValue(Object value)
containsValue in interface Map<String,Object>@Deprecated public Object put(String key, Object value)
@Deprecated public Object remove(Object key)
@Deprecated public void putAll(Map<? extends String,? extends Object> m)
@Deprecated public void clear()
public static ImmutableValueMap of()
Collections.emptyMap(), and is preferable
mainly for consistency
and maintainability of your code.public static ImmutableValueMap of(String k1, Object v1)
Collections.singletonMap(K, V) but will not accept
a null key or value. It is preferable mainly for consistency and
maintainability of your code.public static ImmutableValueMap of(String k1, Object v1, String k2, Object v2)
IllegalArgumentException - if duplicate keys are providedpublic static ImmutableValueMap of(String k1, Object v1, String k2, Object v2, String k3, Object v3)
IllegalArgumentException - if duplicate keys are providedpublic static ImmutableValueMap of(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4)
IllegalArgumentException - if duplicate keys are providedpublic static ImmutableValueMap of(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5)
IllegalArgumentException - if duplicate keys are providedpublic static ImmutableValueMap.Builder builder()
ImmutableValueMap.Builder constructor.public static ImmutableValueMap copyOf(Map<String,Object> map)
map. If map somehow contains entries with
duplicate keys (for example, if
it is a SortedMap whose comparator is not consistent with
equals), the results of this method are undefined.
Despite the method name, this method attempts to avoid actually copying the data when it is safe to do so. The exact circumstances under which a copy will or will not be performed are undocumented and subject to change.
NullPointerException - if any key or value in map is nullCopyright © 2014 wcm.io. All rights reserved.