public class

Maps

extends Object
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.Maps

Class Overview

Utility methods for map.

Summary

Public Constructors
Maps()
Public Methods
static <K, V> V get(Map<K, V> map, K key, V safeValue)
Get a value from a potentially null map.
static <K, V> V get(Map<K, V> map, K key)
Get a value from a potentially null map.
static <K, V> Map<K, V> toMap(K key, V value, Class<? extends Map> c)
Build a map containing 1 element (key, value).
static <K, V> HashMap<K, V> toMap(K key, V value)
Build a HashMap containing 1 element (key, value).
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Maps ()

Public Methods

public static V get (Map<K, V> map, K key, V safeValue)

Get a value from a potentially null map.

Parameters
map optional map
key key
safeValue value returned if the map is null or does not contain the provided key
Returns
  • the value - note: the returned value can be null if the key is present, but points to a null value

public static V get (Map<K, V> map, K key)

Get a value from a potentially null map.

Parameters
map optional map
key key
Returns
  • the value, null if the map is null or contains a key pointing to a null value

public static Map<K, V> toMap (K key, V value, Class<? extends Map> c)

Build a map containing 1 element (key, value).

Parameters
c optional requested map type; use null to obtain a HashMap

public static HashMap<K, V> toMap (K key, V value)

Build a HashMap containing 1 element (key, value).