Class TypedMap

java.lang.Object
dev.voidframework.core.lang.TypedMap

public final class TypedMap extends Object
Typed key-value map.
Since:
1.0.0
  • Constructor Details

    • TypedMap

      public TypedMap()
      Build a new instance.
      Since:
      1.0.0
  • Method Details

    • of

      public static <K, V extends K> TypedMap of(TypedMap.Key<K> key, V value)
      Returns a typed map.
      Type Parameters:
      K - The type of the Key object
      V - The type of the Value object
      Parameters:
      key - The mapping key
      value - The mapping value
      Returns:
      A typed map containing the specified mapping
    • of

      public static <K1, V1 extends K1, K2, V2 extends K2> TypedMap of(TypedMap.Key<K1> key1, V1 value1, TypedMap.Key<K2> key2, V2 value2)
      Returns a typed map.
      Type Parameters:
      K1 - The type of the first Key object
      V1 - The type of the first Value object
      K2 - The type of the second Key object
      V2 - The type of the second Value object
      Parameters:
      key1 - The first mapping key
      value1 - The first mapping value
      key2 - The second mapping key
      value2 - The second mapping value
      Returns:
      A typed map containing the specified mapping
    • of

      public static <K1, V1 extends K1, K2, V2 extends K2, K3, V3 extends K3> TypedMap of(TypedMap.Key<K1> key1, V1 value1, TypedMap.Key<K2> key2, V2 value2, TypedMap.Key<K3> key3, V3 value3)
      Returns a typed map.
      Type Parameters:
      K1 - The type of the first Key object
      V1 - The type of the first Value object
      K2 - The type of the second Key object
      V2 - The type of the second Value object
      K3 - The type of the third Key object
      V3 - The type of the third Value object
      Parameters:
      key1 - The first mapping key
      value1 - The first mapping value
      key2 - The second mapping key
      value2 - The second mapping value
      key3 - The third mapping key
      value3 - The third mapping value
      Returns:
      A typed map containing the specified mapping
    • of

      public static <K1, V1 extends K1, K2, V2 extends K2, K3, V3 extends K3, K4, V4 extends K4> TypedMap of(TypedMap.Key<K1> key1, V1 value1, TypedMap.Key<K2> key2, V2 value2, TypedMap.Key<K3> key3, V3 value3, TypedMap.Key<K4> key4, V4 value4)
      Returns a typed map.
      Type Parameters:
      K1 - The type of the first Key object
      V1 - The type of the first Value object
      K2 - The type of the second Key object
      V2 - The type of the second Value object
      K3 - The type of the third Key object
      V3 - The type of the third Value object
      K4 - The type of the fourth Key object
      V4 - The type of the fourth Value object
      Parameters:
      key1 - The first mapping key
      value1 - The first mapping value
      key2 - The second mapping key
      value2 - The second mapping value
      key3 - The third mapping key
      value3 - The third mapping value
      key4 - The fourth mapping key
      value4 - The fourth mapping value
      Returns:
      A typed map containing the specified mapping
    • get

      public <T> T get(TypedMap.Key<T> typedKey)
      Retrieves the value associated to the specified key.
      Type Parameters:
      T - The value type
      Parameters:
      typedKey - The typed key
      Returns:
      The value associated to the specified key, otherwise, null
      Since:
      1.0.0
    • put

      public <T> T put(TypedMap.Key<T> typedKey, T value)
      Associates the specified value with the specified key.
      Type Parameters:
      T - The value type
      Parameters:
      typedKey - The typed key
      value - The value to associate with the given key
      Returns:
      The previous value associated with key, otherwise, null
      Since:
      1.0.0
    • remove

      public <T> T remove(TypedMap.Key<T> typedKey)
      Removes the value associated to the specified key.
      Type Parameters:
      T - The value type
      Parameters:
      typedKey - The typed key
      Returns:
      The value associated to the specified key, otherwise, null
      Since:
      1.0.0
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object