- java.lang.Object
-
- ch.bind.philib.util.StaticIntMap<T>
-
public final class StaticIntMap<T> extends Object
A statically initialized and immutable map ofint -> T.- Author:
- Philipp Meinen
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(int key)static <T> StaticIntMap<T>create(IntPair<T>[] elements)static <T> StaticIntMap<T>create(Collection<? extends IntPair<T>> elements)Tget(int key)TgetOrElse(int key, T defaultVal)TgetOrThrow(int key)intsize()
-
-
-
Method Detail
-
create
public static <T> StaticIntMap<T> create(Collection<? extends IntPair<T>> elements)
- Parameters:
elements-- Returns:
- A fully initialized
StaticIntMap. - Throws:
IllegalArgumentException- If theelementsparameter isnull, empty or contains duplicate keys.NullPointerException- If any value inelementsis anull-value.
-
create
public static <T> StaticIntMap<T> create(IntPair<T>[] elements)
- Parameters:
elements-- Returns:
- A fully initialized
StaticIntMap. - Throws:
IllegalArgumentException- If theelementsparameter isnull, empty or contains duplicate keys.NullPointerException- If any value inelementsis anull-value.
-
get
public T get(int key)
- Parameters:
key-- Returns:
- The value associated with
key, which may benull.
-
getOrElse
public T getOrElse(int key, T defaultVal)
- Parameters:
key-- Returns:
- The value associated with
key,defaultValotherwise.
-
getOrThrow
public T getOrThrow(int key) throws NoSuchElementException
- Parameters:
key-- Returns:
- The value associated with
key, which may benull. - Throws:
NoSuchElementException- If no value is associated withkey.
-
containsKey
public boolean containsKey(int key)
-
size
public int size()
-
-