Interface ConditionalReadRecordAccessor<K extends Comparable<K>>

Type Parameters:
K - the key type for the record
All Known Subinterfaces:
ConditionalReadWriteRecordAccessor<K>

public interface ConditionalReadRecordAccessor<K extends Comparable<K>>
A ConditionalReadRecordAccessor provides read operations on a record. However, those operations are conditional on the predicate that was used to create the ConditionalReadRecordAccessor.
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Returns true if a record exists that passes the predicate for the key used to create this accessor.
    Reads the record held against the key used to create this ConditionalReadRecordAccessor, if that record matches the predicate used to create this ConditionalReadRecordAccessor.
    default <T> Optional<T>
    read(Function<? super Record<K>,T> mapper)
    Maps the record held against the key used to create this ConditionalReadRecordAccessor, if that record matches the predicate used to create this ConditionalReadRecordAccessor.
  • Method Details

    • read

      default <T> Optional<T> read(Function<? super Record<K>,T> mapper)
      Maps the record held against the key used to create this ConditionalReadRecordAccessor, if that record matches the predicate used to create this ConditionalReadRecordAccessor. The record is mapped using the supplied mapper function and the resulting value is returned.

      An exception thrown from mapper is propagated to the caller of the read method.

      Type Parameters:
      T - the type returned by the function defined in the mapper parameter.
      Parameters:
      mapper - the function to apply to the record.
      Returns:
      an Optional containing the result of applying the function defined in the mapper parameter to the record held against the key if it is present and if it also matches the predicate that was used to create this ConditionalReadRecordAccessor, otherwise an empty Optional.
    • read

      Optional<Record<K>> read()
      Reads the record held against the key used to create this ConditionalReadRecordAccessor, if that record matches the predicate used to create this ConditionalReadRecordAccessor.
      Returns:
      an Optional containing the record held against the key if it is present and if it also matches the predicate that was used to create this ConditionalReadRecordAccessor, otherwise an empty Optional.
    • exists

      default boolean exists()
      Returns true if a record exists that passes the predicate for the key used to create this accessor.
      Returns:
      true if the record exists that passes the predicate.