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 IdentifierCreates anIdentifierfrom aMapof name to value tuples.get(org.springframework.data.relational.core.sql.SqlIdentifier columnName) Collection<org.springframework.data.jdbc.core.convert.Identifier.SingleIdentifierValue>getParts()inthashCode()static Identifierof(org.springframework.data.relational.core.sql.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(org.springframework.data.relational.core.sql.SqlIdentifier name, Object value, Class<?> targetType) Creates a newIdentifierfrom the current instance and sets the value forkey.
-
Method Details
-
empty
Returns an emptyIdentifier.- Returns:
- an empty
Identifier.
-
of
public static Identifier of(org.springframework.data.relational.core.sql.SqlIdentifier name, Object value, Class<?> targetType) - Parameters:
name- must not be null.value- must not be null.targetType- must not be null.- Returns:
- the
Identifierforname,value, and atarget type.
-
from
public static Identifier from(Map<org.springframework.data.relational.core.sql.SqlIdentifier, Object> map) Creates anIdentifierfrom aMapof name to value tuples.- Parameters:
map- must not be null.- Returns:
- the
Identifierfrom aMapof name to value tuples.
-
withPart
public Identifier withPart(org.springframework.data.relational.core.sql.SqlIdentifier name, Object value, Class<?> targetType) 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
Returns aMapcontaining the identifier name to value tuples.- Returns:
- a
Mapcontaining 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 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
public int hashCode() -
toString
-