org.springframework.data.jdbc.core.convert

## Class Identifier

- java.lang.Object
- - org.springframework.data.jdbc.core.convert.Identifier

    public final class Identifier
    extends Object

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 Classes
`static interface` `Identifier.IdentifierConsumer` Represents an operation that accepts identifier key parts (name, value and `target type`) defining a contract to consume `Identifier` values.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static Identifier` `empty()` Returns an empty `Identifier`.
`boolean` `equals(Object o)`
`void` `forEach(Identifier.IdentifierConsumer consumer)` Performs the given action for each element of the `Identifier` until all elements have been processed or the action throws an exception.
`static Identifier` `from(Map<SqlIdentifier,Object> map)` Creates an `Identifier` from a `Map` of name to value tuples.
`Collection<org.springframework.data.jdbc.core.convert.Identifier.SingleIdentifierValue>` `getParts()`
`int` `hashCode()`
`static Identifier` `of(SqlIdentifier name, Object value, Class<?> targetType)` Creates an `Identifier` from `name`, `value`, and a `target type`.
`int` `size()` Returns the number of key parts in this collection.
`Map<SqlIdentifier,Object>` `toMap()` Returns a `Map` containing the identifier name to value tuples.
`String` `toString()`
`Identifier` `withPart(SqlIdentifier name, Object value, Class<?> targetType)` Creates a new `Identifier` from the current instance and sets the value for `key`.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Method Detail

#### empty

    public static Identifier empty()

Returns an empty `Identifier`.

Returns:
  an empty `Identifier`.

#### of

    public static Identifier of(SqlIdentifier name,
                                Object value,
                                Class<?> targetType)

Creates an `Identifier` from `name`, `value`, and a `target type`.

Parameters:
  `name` - must not be null or empty.
  `value` -
  `targetType` - must not be null.
Returns:
  the `Identifier` for `name`, `value`, and a `target type`.

#### from

    public static Identifier from(Map<SqlIdentifier,Object> map)

Creates an `Identifier` from a `Map` of name to value tuples.

Parameters:
  `map` - must not be null.
Returns:
  the `Identifier` from a `Map` of name to value tuples.

#### withPart

    public Identifier withPart(SqlIdentifier name,
                               Object value,
                               Class<?> targetType)

Creates a new `Identifier` from the current instance and sets the value for `key`. Existing key definitions for `name` 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 for `name`, `value`, and a `target type`.

#### toMap

    public Map<SqlIdentifier,Object> toMap()

Returns a `Map` 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

    public void forEach(Identifier.IdentifierConsumer consumer)

Performs the given action for each element of the `Identifier` 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.

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`