Package org.keycloak.models.map.common
Interface StringKeyConverter<K>
-
- All Known Implementing Classes:
StringKeyConverter.StringKey
,StringKeyConverter.ULongKey
,StringKeyConverter.UUIDKey
public interface StringKeyConverter<K>
Converts given storage key from and toString
representation.- Author:
- hmlnarik
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
StringKeyConverter.StringKey
static class
StringKeyConverter.ULongKey
static class
StringKeyConverter.UUIDKey
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description K
fromString(String key)
Returns native representation of the key from String representationdefault K
fromStringSafe(String key)
Exception-free variant offromString(java.lang.String)
method.default String
keyToString(K key)
Returns String representation of the key from native representationK
yieldNewUniqueKey()
Returns a new unique primary key for the storage that thisStringKeyConverter
belongs to.
-
-
-
Method Detail
-
keyToString
default String keyToString(K key)
Returns String representation of the key from native representation- Parameters:
key
-- Returns:
- See above
- Throws:
IllegalArgumentException
- if the string format is not recognizedNullPointerException
- if the parameter isnull
-
yieldNewUniqueKey
K yieldNewUniqueKey()
Returns a new unique primary key for the storage that thisStringKeyConverter
belongs to. The uniqueness needs to be guaranteed by e.g. using database sequences or using a random value that is proved sufficiently improbable to be repeated.- Returns:
-
fromString
K fromString(String key)
Returns native representation of the key from String representation- Parameters:
key
-- Returns:
- See above
- Throws:
IllegalArgumentException
- if the string format is not recognizedNullPointerException
- if the parameter isnull
-
fromStringSafe
default K fromStringSafe(String key)
Exception-free variant offromString(java.lang.String)
method. Returns native representation of the key from String representation, ornull
if thekey
is eithernull
or invalid.- Parameters:
key
-- Returns:
- See above
-
-