Klasse ImmutableValueMap

java.lang.Object
org.apache.sling.testing.mock.sling.builder.ImmutableValueMap
Alle implementierten Schnittstellen:
Map<String,Object>, org.apache.sling.api.resource.ValueMap

@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.

  • Methodendetails

    • get

      @Nullable public <T> T get(@NotNull @NotNull String name, @NotNull @NotNull Class<T> type)
      Angegeben von:
      get in Schnittstelle org.apache.sling.api.resource.ValueMap
    • get

      @NotNull public <T> T get(@NotNull @NotNull String name, @NotNull T defaultValue)
      Angegeben von:
      get in Schnittstelle org.apache.sling.api.resource.ValueMap
    • size

      public int size()
      Angegeben von:
      size in Schnittstelle Map<String,Object>
    • isEmpty

      public boolean isEmpty()
      Angegeben von:
      isEmpty in Schnittstelle Map<String,Object>
    • containsKey

      public boolean containsKey(Object key)
      Angegeben von:
      containsKey in Schnittstelle Map<String,Object>
    • containsValue

      public boolean containsValue(Object value)
      Angegeben von:
      containsValue in Schnittstelle Map<String,Object>
    • get

      public Object get(Object key)
      Angegeben von:
      get in Schnittstelle Map<String,Object>
    • keySet

      public Set<String> keySet()
      Angegeben von:
      keySet in Schnittstelle Map<String,Object>
    • values

      public Collection<Object> values()
      Angegeben von:
      values in Schnittstelle Map<String,Object>
    • entrySet

      public Set<Map.Entry<String,Object>> entrySet()
      Angegeben von:
      entrySet in Schnittstelle Map<String,Object>
    • hashCode

      public int hashCode()
      Angegeben von:
      hashCode in Schnittstelle Map<String,Object>
      Setzt außer Kraft:
      hashCode in Klasse Object
    • equals

      public boolean equals(Object obj)
      Angegeben von:
      equals in Schnittstelle Map<String,Object>
      Setzt außer Kraft:
      equals in Klasse Object
    • toString

      public String toString()
      Setzt außer Kraft:
      toString in Klasse Object
    • put

      @Deprecated public Object put(String key, Object value)
      Veraltet.
      Unsupported operation
      Angegeben von:
      put in Schnittstelle Map<String,Object>
    • remove

      @Deprecated public Object remove(Object key)
      Veraltet.
      Unsupported operation
      Angegeben von:
      remove in Schnittstelle Map<String,Object>
    • putAll

      @Deprecated public void putAll(Map<? extends String,? extends Object> m)
      Veraltet.
      Unsupported operation
      Angegeben von:
      putAll in Schnittstelle Map<String,Object>
    • clear

      @Deprecated public void clear()
      Veraltet.
      Unsupported operation
      Angegeben von:
      clear in Schnittstelle Map<String,Object>
    • of

      @NotNull public static @NotNull ImmutableValueMap of()
      Returns the empty map. This map behaves and performs comparably to Collections.emptyMap(), and is preferable mainly for consistency and maintainability of your code.
      Gibt zurück:
      ImmutableValueMap
    • of

      @NotNull public static @NotNull ImmutableValueMap of(@NotNull @NotNull String k1, @NotNull @NotNull Object v1)
      Returns an immutable map containing a single entry. This map behaves and performs comparably to Collections.singletonMap(K, V) but will not accept a null key or value. It is preferable mainly for consistency and maintainability of your code.
      Parameter:
      k1 - Key 1
      v1 - Value 1
      Gibt zurück:
      ImmutableValueMap
    • of

      @NotNull public static @NotNull ImmutableValueMap of(@NotNull @NotNull String k1, @NotNull @NotNull Object v1, @NotNull @NotNull String k2, @NotNull @NotNull Object v2)
      Returns an immutable map containing the given entries, in order.
      Parameter:
      k1 - Key 1
      v1 - Value 1
      k2 - Key 2
      v2 - Value 2
      Gibt zurück:
      ImmutableValueMap
      Löst aus:
      IllegalArgumentException - if duplicate keys are provided
    • of

      @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)
      Returns an immutable map containing the given entries, in order.
      Parameter:
      k1 - Key 1
      v1 - Value 1
      k2 - Key 2
      v2 - Value 2
      k3 - Key 3
      v3 - Value 3
      Gibt zurück:
      ImmutableValueMap
      Löst aus:
      IllegalArgumentException - if duplicate keys are provided
    • of

      @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)
      Returns an immutable map containing the given entries, in order.
      Parameter:
      k1 - Key 1
      v1 - Value 1
      k2 - Key 2
      v2 - Value 2
      k3 - Key 3
      v3 - Value 3
      k4 - Key 4
      v4 - Value 4
      Gibt zurück:
      ImmutableValueMap
      Löst aus:
      IllegalArgumentException - if duplicate keys are provided
    • of

      public 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)
      Returns an immutable map containing the given entries, in order.
      Parameter:
      k1 - Key 1
      v1 - Value 1
      k2 - Key 2
      v2 - Value 2
      k3 - Key 3
      v3 - Value 3
      k4 - Key 4
      v4 - Value 4
      k5 - Key 5
      v5 - Value 5
      Gibt zurück:
      ImmutableValueMap
      Löst aus:
      IllegalArgumentException - if duplicate keys are provided
    • builder

      @NotNull public static @NotNull ImmutableValueMap.Builder builder()
      Returns a new builder. The generated builder is equivalent to the builder created by the ImmutableValueMap.Builder constructor.
      Gibt zurück:
      Builder
    • copyOf

      @NotNull public static @NotNull ImmutableValueMap copyOf(@NotNull @NotNull Map<String,Object> map)
      Returns an immutable map containing the same entries as 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.

      Parameter:
      map - Map
      Gibt zurück:
      ImmutableValueMap
      Löst aus:
      NullPointerException - if any key or value in map is null