Interface ReadWriteRecordAccessor<K extends Comparable<K>>

Type Parameters:
K - the key type for the record
All Superinterfaces:
ReadRecordAccessor<K>

public interface ReadWriteRecordAccessor<K extends Comparable<K>> extends ReadRecordAccessor<K>
A ReadWriteRecordAccessor provides fine-control over read and write operations on the record held against the key that was used to create the ReadWriteRecordAccessor.
  • Method Details

    • iff

      Read and write operations on the returned ConditionalReadWriteRecordAccessor will have the supplied predicate applied to the record held against the key used to create this ReadWriteRecordAccessor. If the predicate returns false, the operation will proceed as if there is no record against the key. If the predicate returns true, the operation will proceed as normal.
      Specified by:
      iff in interface ReadRecordAccessor<K extends Comparable<K>>
      Parameters:
      predicate - the predicate to apply to the record held against the key used to create this ReadWriteRecordAccessor.
      Returns:
      A ConditionalReadWriteRecordAccessor that provides conditional read and write operations on the record held against the key used to create this ReadWriteRecordAccessor. Any operations using this ConditionalReadWriteRecordAccessor will have the supplied predicate applied to the record held against the key and, if the predicate returns true, the record will be treated as present, otherwise any operation will act as if there is no record against the key.
    • upsert

      default void upsert(Cell<?>... cells)
      Ensures that the record has the supplied cells. If no record exists, a record is created. If there is an existing record then its cells are set to be those supplied. Any cells that were on an existing record that were not in the set of cells supplied will no longer be on the record at the time that the operation completes.
      Parameters:
      cells - the cells to ensure are on the record
    • upsert

      default void upsert(Iterable<Cell<?>> cells)
      Ensures that the record has the supplied cells. If no record exists, a record is created. If there is an existing record then its cells are set to be those supplied. Any cells that were on an existing record that were not in the set of cells supplied will no longer be on the record at the time that the operation completes.
      Parameters:
      cells - a non-null Iterable supplying the cells to ensure are on the record
      Throws:
      NullPointerException - if cells is null
    • upsert

      default void upsert(UpdateOperation<K> update)
      Apply the given update against this record or the empty record if no record exists.

      If there is an existing record then it is updated using the supplied operation. If no record exists, a record is created whose cells are the result of applying the update against an empty record instance.

      Parameters:
      update - a non-null UpdateOperation<K> to apply to the record
      Throws:
      NullPointerException - if update is null
    • add

      default <T> Optional<T> add(Function<? super Record<K>,T> mapper, Cell<?>... cells)
      Creates a record for the key that was used to create this ReadWriteRecordAccessor. If a record is created an empty Optional is returned. If a record existed already, an Optional containing the result of applying the supplied mapper function to the existing record is returned.

      An exception thrown from mapper is propagated to the caller of the add method. The status of the add operation is unaffected by the failure of mapper.

      Type Parameters:
      T - the type returned by the function defined in the mapper parameter.
      Parameters:
      mapper - function to apply to the record held against the key used to create this ReadWriteRecordAccessor, if such a record existed already.
      cells - cells which form the record
      Returns:
      an empty Optional if the record was created, otherwise an Optional containing the result of applying the function defined by the mapper parameter to the record that was already held against the key used to create this ReadWriteRecordAccessor.
    • add

      default <T> Optional<T> add(Function<? super Record<K>,T> mapper, Iterable<Cell<?>> cells)
      Creates a record for the key that was used to create this ReadWriteRecordAccessor. If a record is created an empty Optional is returned. If a record existed already, an Optional containing the result of applying the supplied mapper function to the existing record is returned.

      An exception thrown from mapper is propagated to the caller of the add method. The status of the add operation is unaffected by the failure of mapper.

      Type Parameters:
      T - the type returned by the function defined in the mapper parameter.
      Parameters:
      mapper - function to apply to the record held against the key used to create this ReadWriteRecordAccessor, if such a record existed already.
      cells - a non-null Iterable supplying cells which form the record
      Returns:
      an empty Optional if the record was created, otherwise an Optional containing the result of applying the function defined by the mapper parameter to the record that was already held against the key used to create this ReadWriteRecordAccessor.
      Throws:
      NullPointerException - if cells is null
    • add

      default Optional<Record<K>> add(Cell<?>... cells)
      Creates a record for the key used to create this ReadWriteRecordAccessor. If a record is created an empty Optional is returned. If a record existed already, an Optional containing the existing record is returned.
      Parameters:
      cells - cells which form the record
      Returns:
      an empty Optional if the record was created, otherwise an Optional containing the record that was already held against the key used to create this ReadWriteRecordAccessor.
    • add

      Optional<Record<K>> add(Iterable<Cell<?>> cells)
      Creates a record for the key used to create this ReadWriteRecordAccessor. If a record is created an empty Optional is returned. If a record existed already, an Optional containing the existing record is returned.
      Parameters:
      cells - a non-null Iterable supplying cells which form the record
      Returns:
      an empty Optional if the record was created, otherwise an Optional containing the record that was already held against the key used to create this ReadWriteRecordAccessor.
      Throws:
      NullPointerException - if cells is null
    • update

      default <T> Optional<T> update(UpdateOperation<? super K> transform, BiFunction<? super Record<K>,? super Record<K>,T> mapper)
      Updates a record held against the key used to create this ReadWriteRecordAccessor. If the record is updated, an Optional containing the result of applying the mapper function is returned. If no record to update was found, an empty Optional is returned.

      An exception thrown from mapper is propagated to the caller of the update method. The status of the update operation is unaffected by the failure of mapper.

      Type Parameters:
      T - the type returned by the function defined in the mapper parameter.
      Parameters:
      transform - the mutating transformation to apply to the record
      mapper - the function to apply to the combination of the record that existed before the update and the record that resulted from the update. The first argument to the apply() method will be the record that existed before the update and the second argument will be the record that resulted from the update.
      Returns:
      if a record was held against the key, an Optional containing the result of applying the mapper function to the combination of the record that existed before the update and the record that resulted from the update, otherwise, if there was no record against the key, an empty Optional
    • update

      Optional<Tuple<Record<K>,Record<K>>> update(UpdateOperation<? super K> transform)
      Updates a record held against the key used to create this ReadWriteRecordAccessor. If the record is updated, an Optional containing a Tuple containing the record that existed before the update in the Tuple's first position and the record that resulted from the update in the Tuple's second position, is returned. If there was no record to update, an empty Optional is returned.
      Parameters:
      transform - the mutating transformation to apply to the record
      Returns:
      if a record was held against the key, an Optional containing a Tuple containing the record that existed before the update in the Tuple's first position and the record that resulted from the update in the Tuple's second position, otherwise, if there was no record against the key, an empty Optional
    • delete

      default <T> Optional<T> delete(Function<? super Record<K>,T> mapper)
      Deletes a record held against the key used to create this ReadWriteRecordAccessor. If the record is deleted, an Optional containing the result of applying the mapper function to the deleted record is returned. If there was no record held against the key, an empty Optional is returned.

      An exception thrown from mapper is propagated to the caller of the delete method. The status of the delete operation is unaffected by the failure of mapper.

      Type Parameters:
      T - the type returned by the function defined in the mapper parameter.
      Parameters:
      mapper - function to apply to the deleted record.
      Returns:
      an Optional containing the result of applying the mapper function to the deleted record, or an empty Optional if there was no record held against the key.
    • delete

      Optional<Record<K>> delete()
      Deletes a record held against the key used to create this ReadWriteRecordAccessor. If the record is deleted, an Optional containing the deleted record is returned. If there was no record held against the key, an empty Optional is returned.
      Returns:
      an Optional containing the record deleted, or an empty Optional if there was no record held against the key.