Package me.lucko.luckperms.common.util
Class Difference<T>
java.lang.Object
me.lucko.luckperms.common.util.Difference<T>
- Type Parameters:
T- the value type
Records a log of the changes that occur as a result
of mutations (add or remove operations).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA single change recorded in theDifferencetracker.static enumThe type of change. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all recorded changes.getAdded()Gets the values that have been added.Gets the recorded changes.Gets the recorded changes of a given typeGets the values that have been removed.booleanisEmpty()Gets if no changes have been recorded.mergeFrom(Difference<T> other) Merges the recorded differences inotherinto this.voidrecordChange(Difference.ChangeType type, T value) Records a change.voidrecordChanges(Difference.ChangeType type, Iterable<T> values) Records some changes.toString()
-
Constructor Details
-
Difference
public Difference()
-
-
Method Details
-
getChanges
Gets the recorded changes.- Returns:
- the changes
-
isEmpty
public boolean isEmpty()Gets if no changes have been recorded.- Returns:
- if no changes have been recorded
-
getChanges
Gets the recorded changes of a given type- Parameters:
type- the type of change- Returns:
- the changes
-
getAdded
Gets the values that have been added.- Returns:
- the added values
-
getRemoved
Gets the values that have been removed.- Returns:
- the removed values
-
clear
public void clear()Clears all recorded changes. -
recordChange
Records a change.- Parameters:
type- the type of changevalue- the changed value
-
recordChanges
Records some changes.- Parameters:
type- the type of changevalues- the changed values
-
mergeFrom
Merges the recorded differences inotherinto this.- Parameters:
other- the other differences- Returns:
- this
-
toString
-