K
- the key type for the recordpublic interface ReadWriteRecordAccessor<K extends java.lang.Comparable<K>> extends ReadRecordAccessor<K>
Modifier and Type | Method and Description |
---|---|
default java.util.Optional<Record<K>> |
add(Cell<?>... cells)
Creates a record for the key used to create this ReadWriteRecordAccessor.
|
default <T> java.util.Optional<T> |
add(java.util.function.Function<? super Record<K>,T> mapper,
Cell<?>... cells)
Creates a record for the key that was used to create this ReadWriteRecordAccessor.
|
default <T> java.util.Optional<T> |
add(java.util.function.Function<? super Record<K>,T> mapper,
java.lang.Iterable<Cell<?>> cells)
Creates a record for the key that was used to create this ReadWriteRecordAccessor.
|
java.util.Optional<Record<K>> |
add(java.lang.Iterable<Cell<?>> cells)
Creates a record for the key used to create this ReadWriteRecordAccessor.
|
java.util.Optional<Record<K>> |
delete()
Deletes a record held against the key used to create this ReadWriteRecordAccessor.
|
default <T> java.util.Optional<T> |
delete(java.util.function.Function<? super Record<K>,T> mapper)
Deletes a record held against the key used to create this ReadWriteRecordAccessor.
|
ConditionalReadWriteRecordAccessor<K> |
iff(java.util.function.Predicate<? super Record<K>> predicate)
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.
|
java.util.Optional<Tuple<Record<K>,Record<K>>> |
update(UpdateOperation<? super K> transform)
Updates a record held against the key used to create this ReadWriteRecordAccessor.
|
default <T> java.util.Optional<T> |
update(UpdateOperation<? super K> transform,
java.util.function.BiFunction<? super Record<K>,? super Record<K>,T> mapper)
Updates a record held against the key used to create this ReadWriteRecordAccessor.
|
default void |
upsert(Cell<?>... cells)
Ensures that the record has the supplied cells.
|
default void |
upsert(java.lang.Iterable<Cell<?>> cells)
Ensures that the record has the supplied cells.
|
default void |
upsert(UpdateOperation<K> update)
Apply the given update against this record or the empty record if no record exists.
|
getKey, read
ConditionalReadWriteRecordAccessor<K> iff(java.util.function.Predicate<? super Record<K>> predicate)
iff
in interface ReadRecordAccessor<K extends java.lang.Comparable<K>>
predicate
- the predicate to apply to the record held against the key used to create
this ReadWriteRecordAccessor.default void upsert(Cell<?>... cells)
cells
- the cells to ensure are on the recorddefault void upsert(java.lang.Iterable<Cell<?>> cells)
cells
- a non-null
Iterable
supplying the cells to ensure are on the recordjava.lang.NullPointerException
- if cells
is null
default void upsert(UpdateOperation<K> update)
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.
update
- a non-null
UpdateOperation<K>
to apply to the recordjava.lang.NullPointerException
- if update
is null
default <T> java.util.Optional<T> add(java.util.function.Function<? super Record<K>,T> mapper, Cell<?>... cells)
T
- the type returned by the function defined in the mapper parameter.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 recorddefault <T> java.util.Optional<T> add(java.util.function.Function<? super Record<K>,T> mapper, java.lang.Iterable<Cell<?>> cells)
T
- the type returned by the function defined in the mapper parameter.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 recordjava.lang.NullPointerException
- if cells
is null
default java.util.Optional<Record<K>> add(Cell<?>... cells)
cells
- cells which form the recordjava.util.Optional<Record<K>> add(java.lang.Iterable<Cell<?>> cells)
cells
- a non-null
Iterable
supplying cells which form the recordjava.lang.NullPointerException
- if cells
is null
default <T> java.util.Optional<T> update(UpdateOperation<? super K> transform, java.util.function.BiFunction<? super Record<K>,? super Record<K>,T> mapper)
T
- the type returned by the function defined in the mapper parameter.transform
- the mutating transformation to apply to the recordmapper
- 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.java.util.Optional<Tuple<Record<K>,Record<K>>> update(UpdateOperation<? super K> transform)
transform
- the mutating transformation to apply to the recorddefault <T> java.util.Optional<T> delete(java.util.function.Function<? super Record<K>,T> mapper)
T
- the type returned by the function defined in the mapper parameter.mapper
- function to apply to the deleted record.java.util.Optional<Record<K>> delete()