Class Identifier
java.lang.Object
org.springframework.data.jdbc.core.convert.Identifier
Identifier represents a composite id of an entity that may be composed of one or many parts. Parts or all
of the entity might not have a representation as a property in the entity but might only be derived from other
entities referencing it.
- Since:
- 1.1
- Author:
- Jens Schauder, Mark Paluch
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Represents an operation that accepts identifier key parts (name, value andtarget type
) defining a contract to consumeIdentifier
values. -
Method Summary
Modifier and TypeMethodDescriptionstatic Identifier
empty()
Returns an emptyIdentifier
.boolean
void
forEach
(Identifier.IdentifierConsumer consumer) Performs the given action for each element of theIdentifier
until all elements have been processed or the action throws an exception.static Identifier
from
(Map<SqlIdentifier, Object> map) Creates anIdentifier
from aMap
of name to value tuples.get
(SqlIdentifier columnName) Collection<org.springframework.data.jdbc.core.convert.Identifier.SingleIdentifierValue>
getParts()
int
hashCode()
static Identifier
of
(SqlIdentifier name, Object value, Class<?> targetType) int
size()
Returns the number of key parts in this collection.toMap()
Returns aMap
containing the identifier name to value tuples.toString()
withPart
(SqlIdentifier name, Object value, Class<?> targetType) Creates a newIdentifier
from the current instance and sets the value forkey
.
-
Method Details
-
empty
Returns an emptyIdentifier
.- Returns:
- an empty
Identifier
.
-
of
- Parameters:
name
- must not be null or empty.value
-targetType
- must not be null.- Returns:
- the
Identifier
forname
,value
, and atarget type
.
-
from
Creates anIdentifier
from aMap
of name to value tuples.- Parameters:
map
- must not be null.- Returns:
- the
Identifier
from aMap
of name to value tuples.
-
withPart
Creates a newIdentifier
from the current instance and sets the value forkey
. Existing key definitions forname
are overwritten if they already exist.- Parameters:
name
- must not be null or empty.value
-targetType
- must not be null.- Returns:
- the
Identifier
containing all existing keys and the key part forname
,value
, and atarget type
.
-
toMap
Returns aMap
containing the identifier name to value tuples.- Returns:
- a
Map
containing the identifier name to value tuples.
-
getParts
public Collection<org.springframework.data.jdbc.core.convert.Identifier.SingleIdentifierValue> getParts()- Returns:
- the
key parts
.
-
forEach
Performs the given action for each element of theIdentifier
until all elements have been processed or the action throws an exception. Unless otherwise specified by the implementing class, actions are performed in the order of iteration (if an iteration order is specified). Exceptions thrown by the action are relayed to the caller.- Parameters:
consumer
- the action, must not be null.
-
size
public int size()Returns the number of key parts in this collection.- Returns:
- the number of key parts in this collection.
-
get
-
equals
-
hashCode
public int hashCode() -
toString
-