Package com.identityworksllc.iiq.common
Interface TypeFriendlyMap<K,V>
-
- Type Parameters:
K
- The key typeV
- The value type
- All Superinterfaces:
Map<K,V>
- All Known Implementing Classes:
TypeFriendlyConcurrentHashMap
,TypeFriendlyDelegatedConcurrentMap
,TypeFriendlyDelegatedMap
,TypeFriendlyHashMap
public interface TypeFriendlyMap<K,V> extends Map<K,V>
An extension to the Map interface that adds a bunch of default typed getXXX methods.All other methods, such as
Map.get(Object)
are to be implemented by the actual concrete Map implementation.You can use
fromMap(Map)
to retrieve a copy of your Map implementing this interface.
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description static <K,V>
TypeFriendlyMap<K,V>fromMap(Map<K,V> input)
Decorates the input Map with the TypeFriendlyMap interface.default <T extends V>
TgetAs(K key, Class<T> targetClass)
Gets the given value cast to the given type.default boolean
getBoolean(K key)
default int
getInt(K key)
default long
getLong(K key)
default <T extends sailpoint.object.SailPointObject>
TgetSailPointObject(K key, sailpoint.api.SailPointContext context, Class<T> targetClass)
Gets the given value cast to the given SailPointObject type.default String
getString(K key)
default List<String>
getStringList(K key)
-
Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Method Detail
-
fromMap
static <K,V> TypeFriendlyMap<K,V> fromMap(Map<K,V> input)
Decorates the input Map with the TypeFriendlyMap interface.This does not make a copy of the input. All Map interface methods will be delegated to the decorated Map.
- Type Parameters:
K
- The key typeV
- The value type- Parameters:
input
- The input map to decorate- Returns:
- The decorated Map object
-
getAs
default <T extends V> T getAs(K key, Class<T> targetClass)
Gets the given value cast to the given type.If the value is null, a null will be returned. If the value cannot be cast to the given type, a ClassCastException will be thrown.
- Type Parameters:
T
- The output type- Parameters:
key
- The key to get the value fortargetClass
- The target class to cast the value to- Returns:
- The output object cast to the given class
- Throws:
ClassCastException
- if the value is not compatible with the target class
-
getBoolean
default boolean getBoolean(K key)
-
getSailPointObject
default <T extends sailpoint.object.SailPointObject> T getSailPointObject(K key, sailpoint.api.SailPointContext context, Class<T> targetClass) throws sailpoint.tools.GeneralException
Gets the given value cast to the given SailPointObject type.If the stored value is a String and not the target type, it will be assumed to be a name or ID and the SailPointContext provided will be invoked to look it up.
- Type Parameters:
T
- The SailPointObject type to query- Parameters:
key
- The key to get the value fortargetClass
- The target class to cast the value to- Returns:
- The output object cast to the given class
- Throws:
ClassCastException
- if the value is not compatible with the target classsailpoint.tools.GeneralException
- if any errors occur reading the SPO from the context
-
getStringList
default List<String> getStringList(K key)
-
-