Interface Entity.Key

Enclosing interface:
Entity

public static interface Entity.Key
Represents a unique column combination for a given entity.
  • Method Details

    • entityType

      EntityType entityType()
      Returns:
      the entity type
    • entityDefinition

      EntityDefinition entityDefinition()
      Returns:
      the entity definition
    • columns

      Collection<Column<?>> columns()
      Note that the column order is undefined here, for the primary key columns in the correct (indexed) order EntityDefinition.PrimaryKey.columns() via EntityDefinition.primaryKey().
      Returns:
      the columns comprising this key
    • primaryKey

      boolean primaryKey()
      Returns:
      true if this key represents a primary key for an entity, note that this is true for empty keys representing entities without a defined primary key
    • isNull

      boolean isNull()
      Returns:
      true if this key contains no values or if it contains a null value for a non-nullable key attribute
    • isNotNull

      boolean isNotNull()
      Returns:
      true if no non-nullable values are null
    • isNull

      boolean isNull(Column<?> column)
      Returns true if a null value is mapped to the given column or no mapping exists.
      Parameters:
      column - the column
      Returns:
      true if the value mapped to the given column is null or none exists
    • isNotNull

      boolean isNotNull(Column<?> column)
      Returns true if a non-null value is mapped to the given column.
      Parameters:
      column - the column
      Returns:
      true if a non-null value is mapped to the given column
    • column

      <T> Column<T> column()
      Returns this keys column. Note that this method throws an exception if this key is a composite key.
      Type Parameters:
      T - the column type
      Returns:
      the key column, useful for single column keys
      Throws:
      IllegalStateException - in case this is a composite key
      NoSuchElementException - in case this key contains no values
    • get

      <T> T get()
      Returns the value of this key. Note that this method throws an exception if this key is a composite key.
      Type Parameters:
      T - the value type
      Returns:
      the first value contained in this key, useful for single attribute keys
      Throws:
      IllegalStateException - in case this is a composite key
      NoSuchElementException - in case this key contains no values
    • optional

      <T> Optional<T> optional()
      Returns the value of this key, wrapped in an Optional. Note that this method throws an exception if this key is a composite key.
      Type Parameters:
      T - the value type
      Returns:
      the first value contained in this key, wrapped in an Optional, useful for single attribute keys
      Throws:
      IllegalStateException - in case this is a composite key
      NoSuchElementException - in case this key contains no values
    • get

      <T> T get(Column<T> column)
      Type Parameters:
      T - the value type
      Parameters:
      column - the column
      Returns:
      the value associated with the given column
      Throws:
      IllegalArgumentException - in case this column is not part of this key
    • optional

      <T> Optional<T> optional(Column<T> column)
      Type Parameters:
      T - the value type
      Parameters:
      column - the column
      Returns:
      the value associated with the given column, wrapped in an Optional
      Throws:
      IllegalArgumentException - in case this column is not part of this key
    • copyBuilder

      Entity.Key.Builder copyBuilder()
      Creates a new Entity.Key.Builder instance, initialized with the values in this key.
      Returns:
      a new builder based on this key