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
Nested ClassesModifier and TypeClassDescriptionstatic interfaceRepresents an operation that accepts identifier key parts (name, value andtarget type) defining a contract to consumeIdentifiervalues. -
Method Summary
Modifier and TypeMethodDescriptionstatic Identifierempty()Returns an emptyIdentifier.booleanvoidforEach(Identifier.IdentifierConsumer consumer) Performs the given action for each element of theIdentifieruntil all elements have been processed or the action throws an exception.static Identifierfrom(Map<SqlIdentifier, Object> map) Creates anIdentifierfrom aMapof name to value tuples.@Nullable Objectget(SqlIdentifier columnName) Collection<org.springframework.data.jdbc.core.convert.Identifier.SingleIdentifierValue> getParts()inthashCode()static Identifierof(SqlIdentifier name, Object value, Class<?> targetType) intsize()Returns the number of key parts in this collection.toMap()Returns aMapcontaining the identifier name to value tuples.toString()withPart(Identifier identifier) Creates a newIdentifierfrom the current instance and sets the value fromIdentifier.withPart(SqlIdentifier name, Object value, Class<?> targetType) Creates a newIdentifierfrom the current instance and sets the value forkey.
-
Method Details
-
empty
-
of
- Parameters:
name- must not be null.value- must not be null.targetType- must not be null.- Returns:
- the
Identifierforname,value, and atarget type.
-
from
Creates anIdentifierfrom aMapof name to value tuples.- Parameters:
map- must not be null.- Returns:
- the
Identifierfrom aMapof name to value tuples.
-
withPart
Creates a newIdentifierfrom the current instance and sets the value fromIdentifier. Existing key definitions fornameare overwritten if they already exist.- Parameters:
identifier- the identifier to append.- Returns:
- the
Identifiercontaining all existing keys and the key part forname,value, and atarget type. - Since:
- 4.0
-
withPart
Creates a newIdentifierfrom the current instance and sets the value forkey. Existing key definitions fornameare overwritten if they already exist.- Parameters:
name- must not be null or empty.value-targetType- must not be null.- Returns:
- the
Identifiercontaining all existing keys and the key part forname,value, and atarget type.
-
toMap
-
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 theIdentifieruntil 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
-
toString
-