Interface ReadRecordAccessor<K extends Comparable<K>>

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

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

    Modifier and Type
    Method
    Description
    default boolean
    Returns true if a record exists for the key used to create this accessor.
    Returns the key that this accessor is against.
    iff(Predicate<? super Record<K>> predicate)
    Read operations on the returned ConditionalReadRecordAccessor will have the supplied predicate applied to the record held against the key used to create this ReadRecordAccessor.
    <T> Optional<T>
    read(Function<? super Record<K>,T> mapper)
    Maps the record held against the key used to create this ReadRecordAccessor.
  • Method Details

    • getKey

      K getKey()
      Returns the key that this accessor is against.
      Returns:
      the accessed key
    • iff

      ConditionalReadRecordAccessor<K> iff(Predicate<? super Record<K>> predicate)
      Read operations on the returned ConditionalReadRecordAccessor will have the supplied predicate applied to the record held against the key used to create this ReadRecordAccessor. If the predicate returns false, the read will proceed as if there is no record against the key. If the predicate returns true, the read will proceed as normal.
      Parameters:
      predicate - the predicate to apply to the record held against the key used to create this ReadRecordAccessor.
      Returns:
      A ConditionalReadRecordAccessor that provides conditional read operations on the record held against the key used to create this ReadRecordAccessor. Any reads using this ConditionalReadRecordAccessor will have the supplied predicate applied to the record held against the key and, if the predicate returns true, the record will be read, otherwise any read will act as if there is no record against the key.
    • read

      <T> Optional<T> read(Function<? super Record<K>,T> mapper)
      Maps the record held against the key used to create this ReadRecordAccessor. The record is mapped by applying 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, otherwise an empty Optional.
    • exists

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