Package com.terracottatech.store
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 TypeMethodDescriptiondefault boolean
exists()
Returnstrue
if a record exists that passes the predicate for the key used to create this accessor.read()
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>
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
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 theread
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
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()Returnstrue
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.
-