Package org.jgrapes.core
Class TypedIdKey<V>
java.lang.Object
org.jgrapes.core.TypedIdKey<V>
- All Implemented Interfaces:
Serializable
Combines a type and an id value to a key for an
Associator
or Map
.This kind of key can be used if an instance of the type as key is too specific (or objects should not be kept alive only because they are used as keys) and the identifier alone cannot be guaranteed to be unique.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> V
associate
(Associator associator, Serializable id, V value) Associates the given value’s type and the id with the given value using the given associator.static <V> Optional
<V> associated
(Associator associator, Class<V> type, Serializable id) Retrieves a value with the given type and id from the given associator.boolean
static <V> Optional
<V> get
(Map<?, ?> map, Class<V> type, Serializable id) Retrieves a value with the given type and id from the given map.int
hashCode()
static <V> V
put
(Map<? super TypedIdKey<V>, ? super V> map, Serializable id, V value) Associates the given value’s type and the id with the given value using the given map.toString()
-
Method Details
-
associate
Associates the given value’s type and the id with the given value using the given associator.- Type Parameters:
V
- the value type- Parameters:
associator
- the associatorid
- the idvalue
- the value- Returns:
- the value for easy chaining
-
put
Associates the given value’s type and the id with the given value using the given map.- Type Parameters:
V
- the value type- Parameters:
map
- the mapid
- the idvalue
- the value- Returns:
- the value for easy chaining
-
associated
Retrieves a value with the given type and id from the given associator.- Type Parameters:
V
- the value type- Parameters:
associator
- the associatortype
- the typeid
- the id- Returns:
- the associated value, if any
-
get
Retrieves a value with the given type and id from the given map.- Type Parameters:
V
- the value type- Parameters:
map
- the maptype
- the typeid
- the id- Returns:
- the associated value, if any
-
hashCode
-
equals
-
toString
-