Package org.keycloak.models.map.common
Interface EntityField<E>
-
- Type Parameters:
E
-
- All Known Implementing Classes:
MapAdminEventEntityFields
,MapAuthenticatedClientSessionEntityFields
,MapAuthenticationExecutionEntityFields
,MapAuthenticationFlowEntityFields
,MapAuthenticationSessionEntityFields
,MapAuthenticatorConfigEntityFields
,MapAuthEventEntityFields
,MapClientEntityFields
,MapClientInitialAccessEntityFields
,MapClientScopeEntityFields
,MapComponentEntityFields
,MapGroupEntityFields
,MapIdentityProviderEntityFields
,MapIdentityProviderMapperEntityFields
,MapOTPPolicyEntityFields
,MapPermissionTicketEntityFields
,MapPolicyEntityFields
,MapProtocolMapperEntityFields
,MapRealmEntityFields
,MapRequiredActionProviderEntityFields
,MapRequiredCredentialEntityFields
,MapResourceEntityFields
,MapResourceServerEntityFields
,MapRoleEntityFields
,MapRootAuthenticationSessionEntityFields
,MapScopeEntityFields
,MapSingleUseObjectEntityFields
,MapUserConsentEntityFields
,MapUserCredentialEntityFields
,MapUserEntityFields
,MapUserFederatedIdentityEntityFields
,MapUserLoginFailureEntityFields
,MapUserSessionEntityFields
,MapWebAuthnPolicyEntityFields
public interface EntityField<E>
Represents a field in an entity with appropriate accessors.- Author:
- hmlnarik
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <T> void
collectionAdd(E e, T value)
Adds an element to the collection stored in this field.default <T> Object
collectionRemove(E e, T value)
Removes an element from the collection stored in this field.Object
get(E e)
Returns the value of this field.default Class<?>
getCollectionElementClass()
default Class<?>
getFieldClass()
default Class<?>
getMapKeyClass()
default Class<?>
getMapValueClass()
String
getName()
Returns name of this field with no spaces where each word starts with a capital letter.String
getNameCamelCase()
String
getNameDashed()
Returns name of this field in lowercase with words separated by a dash (-
).default <K> Object
mapGet(E e, K key)
Retrieves a value from the map stored in this field.default <K,T>
voidmapPut(E e, K key, T value)
Adds a mapping to the map stored in this field.default <K> Object
mapRemove(E e, K key)
Removes a mapping from the map stored in this field.default <T> void
set(E e, T value)
Sets the value of this field.
-
-
-
Method Detail
-
getName
String getName()
Returns name of this field with no spaces where each word starts with a capital letter.- Returns:
-
getNameCamelCase
String getNameCamelCase()
-
getNameDashed
String getNameDashed()
Returns name of this field in lowercase with words separated by a dash (-
).- Returns:
-
get
Object get(E e)
Returns the value of this field.- Parameters:
e
- Entity- Returns:
- Value of the field
-
set
default <T> void set(E e, T value)
Sets the value of this field. Does nothing by default. If you want to have a field set, override this method.- Type Parameters:
T
-- Parameters:
e
- Entityvalue
- Value of the field
-
collectionAdd
default <T> void collectionAdd(E e, T value)
Adds an element to the collection stored in this field.- Parameters:
e
- Entityvalue
- Value to be added to the collection- Throws:
ClassCastException
- If this field is not a collection.UnsupportedOperationException
- If this collection type is not yet known.
-
collectionRemove
default <T> Object collectionRemove(E e, T value)
Removes an element from the collection stored in this field.- Parameters:
e
- Entityvalue
- Value to be added to the collection- Returns:
- Defined by the underlying field. Preferrably it should return deleted object, but it can return
true / false
indication of removal, or justnull
. - Throws:
ClassCastException
- If this field is not a collection.
-
mapGet
default <K> Object mapGet(E e, K key)
Retrieves a value from the map stored in this field.- Parameters:
e
- Entitykey
- Requested key- Returns:
- Object mapped to this key
- Throws:
ClassCastException
- If this field is not a map.
-
mapPut
default <K,T> void mapPut(E e, K key, T value)
Adds a mapping to the map stored in this field.- Parameters:
e
- Entitykey
- Key to mapvalue
- Mapped value- Throws:
ClassCastException
- If this field is not a map.
-
mapRemove
default <K> Object mapRemove(E e, K key)
Removes a mapping from the map stored in this field.- Parameters:
e
- Entitykey
- Key to remove- Returns:
- Object mapped to this key
- Throws:
ClassCastException
- If this field is not a map.
-
getFieldClass
default Class<?> getFieldClass()
- Returns:
- Returns the most specific type of this field.
-
getCollectionElementClass
default Class<?> getCollectionElementClass()
- Returns:
- If this field is a collection, returns type of its elements; otherwise returns
Void
class.
-
getMapKeyClass
default Class<?> getMapKeyClass()
- Returns:
- If this field is a map, returns type of its keys; otherwise returns
Void
class.
-
getMapValueClass
default Class<?> getMapValueClass()
- Returns:
- If this field is a map, returns type of its values; otherwise returns
Void
class.
-
-