@ProviderType 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 @NotNull ImmutableValueMap.Builder |
builder()
Returns a new builder.
|
void |
clear()
Deprecated.
Unsupported operation
|
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
static @NotNull ImmutableValueMap |
copyOf(@NotNull Map<String,Object> map)
Returns an immutable map containing the same entries as
map. |
Set<Map.Entry<String,Object>> |
entrySet() |
boolean |
equals(Object obj) |
Object |
get(Object key) |
<T> T |
get(String name,
Class<T> type) |
<T> T |
get(String name,
T defaultValue) |
int |
hashCode() |
boolean |
isEmpty() |
Set<String> |
keySet() |
static @NotNull ImmutableValueMap |
of()
Returns the empty map.
|
static @NotNull ImmutableValueMap |
of(@NotNull String k1,
@NotNull Object v1)
Returns an immutable map containing a single entry.
|
static @NotNull ImmutableValueMap |
of(@NotNull String k1,
@NotNull Object v1,
@NotNull String k2,
@NotNull Object v2)
Returns an immutable map containing the given entries, in order.
|
static @NotNull ImmutableValueMap |
of(@NotNull String k1,
@NotNull Object v1,
@NotNull String k2,
@NotNull Object v2,
@NotNull String k3,
@NotNull Object v3)
Returns an immutable map containing the given entries, in order.
|
static @NotNull ImmutableValueMap |
of(@NotNull String k1,
@NotNull Object v1,
@NotNull String k2,
@NotNull Object v2,
@NotNull String k3,
@NotNull Object v3,
@NotNull String k4,
@NotNull Object v4)
Returns an immutable map containing the given entries, in order.
|
static ImmutableValueMap |
of(@NotNull String k1,
@NotNull Object v1,
@NotNull String k2,
@NotNull Object v2,
@NotNull String k3,
@NotNull Object v3,
@NotNull String k4,
@NotNull Object v4,
@NotNull String k5,
@NotNull 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() |
String |
toString() |
Collection<Object> |
values() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic <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>public int hashCode()
public boolean equals(Object obj)
@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()
@NotNull public static @NotNull ImmutableValueMap of()
Collections.emptyMap(), and is preferable
mainly for consistency
and maintainability of your code.@NotNull public static @NotNull ImmutableValueMap of(@NotNull @NotNull String k1, @NotNull @NotNull 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.k1 - Key 1v1 - Value 1@NotNull public static @NotNull ImmutableValueMap of(@NotNull @NotNull String k1, @NotNull @NotNull Object v1, @NotNull @NotNull String k2, @NotNull @NotNull Object v2)
k1 - Key 1v1 - Value 1k2 - Key 2v2 - Value 2IllegalArgumentException - if duplicate keys are provided@NotNull public static @NotNull ImmutableValueMap of(@NotNull @NotNull String k1, @NotNull @NotNull Object v1, @NotNull @NotNull String k2, @NotNull @NotNull Object v2, @NotNull @NotNull String k3, @NotNull @NotNull Object v3)
k1 - Key 1v1 - Value 1k2 - Key 2v2 - Value 2k3 - Key 3v3 - Value 3IllegalArgumentException - if duplicate keys are provided@NotNull public static @NotNull ImmutableValueMap of(@NotNull @NotNull String k1, @NotNull @NotNull Object v1, @NotNull @NotNull String k2, @NotNull @NotNull Object v2, @NotNull @NotNull String k3, @NotNull @NotNull Object v3, @NotNull @NotNull String k4, @NotNull @NotNull Object v4)
k1 - Key 1v1 - Value 1k2 - Key 2v2 - Value 2k3 - Key 3v3 - Value 3k4 - Key 4v4 - Value 4IllegalArgumentException - if duplicate keys are providedpublic static ImmutableValueMap of(@NotNull @NotNull String k1, @NotNull @NotNull Object v1, @NotNull @NotNull String k2, @NotNull @NotNull Object v2, @NotNull @NotNull String k3, @NotNull @NotNull Object v3, @NotNull @NotNull String k4, @NotNull @NotNull Object v4, @NotNull @NotNull String k5, @NotNull @NotNull Object v5)
k1 - Key 1v1 - Value 1k2 - Key 2v2 - Value 2k3 - Key 3v3 - Value 3k4 - Key 4v4 - Value 4k5 - Key 5v5 - Value 5IllegalArgumentException - if duplicate keys are provided@NotNull public static @NotNull ImmutableValueMap.Builder builder()
ImmutableValueMap.Builder constructor.@NotNull public static @NotNull ImmutableValueMap copyOf(@NotNull @NotNull 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.
map - MapNullPointerException - if any key or value in map is nullCopyright © 2014–2019 wcm.io. All rights reserved.