V - the type of mapped objectspublic class KeyMapper<V> extends Object implements DataKeyMapper<V>
KeyMapper is the simple two-way map for generating textual keys
for objects and retrieving the objects later with the key.| Constructor and Description |
|---|
KeyMapper()
Constructs a new mapper with trivial
identifierGetter |
KeyMapper(ValueProvider<V,Object> identifierGetter)
Constructs a new mapper.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsKey(String key)
Checks if the given key is mapped to an object.
|
protected String |
createKey()
Creates a key for a new item.
|
V |
get(String key)
Retrieves object with the key.
|
boolean |
has(V o)
Check whether this key mapper contains the given data object.
|
String |
key(V o)
Gets key for an object.
|
void |
refresh(V dataObject)
Updates any existing mappings of given data object.
|
void |
remove(V removeobj)
Removes object from the mapper.
|
void |
removeAll()
Removes all objects from the mapper.
|
void |
setIdentifierGetter(ValueProvider<V,Object> identifierGetter)
Takes identifier getter into use and updates existing mappings
|
public KeyMapper(ValueProvider<V,Object> identifierGetter)
identifierGetter - has to return a unique key for every bean, and the returned
key has to follow general hashCode() and
equals() contract, see Object.hashCode() for
details.public KeyMapper()
identifierGetterpublic String key(V o)
key in interface DataKeyMapper<V>o - the object.protected String createKey()
public boolean has(V o)
DataKeyMapperhas in interface DataKeyMapper<V>o - the data object to checktrue if the given data object is contained in this key
mapper, false otherwisepublic V get(String key)
get in interface DataKeyMapper<V>key - the name with the desired value.public void remove(V removeobj)
remove in interface DataKeyMapper<V>removeobj - the object to be removed.public void removeAll()
removeAll in interface DataKeyMapper<V>public boolean containsKey(String key)
key - the key to checktrue if the key is currently mapped,
false otherwisepublic void refresh(V dataObject)
DataKeyMapperrefresh in interface DataKeyMapper<V>dataObject - the data object to updatepublic void setIdentifierGetter(ValueProvider<V,Object> identifierGetter)
DataKeyMappersetIdentifierGetter in interface DataKeyMapper<V>identifierGetter - has to return a unique key for every bean, and the returned
key has to follow general hashCode() and
equals() contract, see Object.hashCode() for
details.Copyright © 2025. All rights reserved.