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
  • Method Details

    • 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.
    • get

      @Nullable public Object get(SqlIdentifier columnName)
    • equals

      public boolean equals(@Nullable 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