public abstract class Mutation<E,K> extends Object
Constructor and Description |
---|
Mutation() |
Mutation(List<E> additions,
List<K> deletions) |
Mutation(Supplier<List<E>> additionsCopySupplier,
Supplier<List<K>> deletionsCopySupplier) |
Modifier and Type | Method and Description |
---|---|
void |
addition(E entry)
Adds a new entry as an addition to this mutation
|
abstract void |
consolidate() |
<V> void |
consolidate(Function<E,V> convertAdditions,
Function<K,V> convertDeletions)
Consolidates this mutation by removing redundant deletions.
|
void |
deletion(K key)
Adds a new key as a deletion to this mutation
|
List<E> |
getAdditions()
Returns the list of additions in this mutation
|
List<K> |
getDeletions()
Returns the list of deletions in this mutation.
|
int |
getTotalMutations() |
boolean |
hasAdditions()
Whether this mutation has additions
|
boolean |
hasDeletions()
Whether this mutation has deletions
|
abstract boolean |
isConsolidated() |
<V> boolean |
isConsolidated(Function<E,V> convertAdditions,
Function<K,V> convertDeletions)
Checks whether this mutation is consolidated in the sense of
consolidate(Function, Function) . |
boolean |
isEmpty() |
void |
merge(Mutation<E,K> m)
Merges another mutation into this mutation.
|
public Mutation(Supplier<List<E>> additionsCopySupplier, Supplier<List<K>> deletionsCopySupplier)
public Mutation()
public boolean hasAdditions()
public boolean hasDeletions()
public void addition(E entry)
entry
- public void deletion(K key)
key
- public void merge(Mutation<E,K> m)
m
- public boolean isEmpty()
public int getTotalMutations()
public <V> void consolidate(Function<E,V> convertAdditions, Function<K,V> convertDeletions)
The provided conversion functions map additions and deletions into some object space V for comparison. An addition is considered identical to a deletion if both map to the same object (i.e. equals=true) with the respective conversion functions.
It needs to be ensured that V objects have valid hashCode() and equals() implementations.
convertAdditions
- Function which maps additions onto comparison objects.convertDeletions
- Function which maps deletions onto comparison objects.public abstract void consolidate()
public <V> boolean isConsolidated(Function<E,V> convertAdditions, Function<K,V> convertDeletions)
consolidate(Function, Function)
.
This should only be used in assertions and tests due to the performance penalty.V
- convertAdditions
- convertDeletions
- public abstract boolean isConsolidated()
Copyright © 2012–2024. All rights reserved.