Package com.fizzed.crux.util
Class Agg.OrderedValue<T>
- java.lang.Object
-
- com.fizzed.crux.util.Agg.OrderedValue<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Comparator<? super T>comparatorprotected Tvalue
-
Constructor Summary
Constructors Modifier Constructor Description protectedOrderedValue(java.util.Comparator<? super T> comparator, T initialValue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapply(T newValue)Null-safe apply a new value, calculate the agg (e.g.booleanapply(T newValue, boolean includeNulls)Apply a new value, calculate the agg, and returns the new value.voidclear()Clears the current value by setting it to null.Tget()Gets the current value.booleanisAbsent()booleanisPresent()Maybe<T>maybe()voidset(T value)Directly sets the current value.
-
-
-
Method Detail
-
isAbsent
public boolean isAbsent()
-
isPresent
public boolean isPresent()
-
clear
public void clear()
Clears the current value by setting it to null.
-
set
public void set(T value)
Directly sets the current value.- Parameters:
value-
-
get
public T get()
Gets the current value.- Returns:
-
apply
public boolean apply(T newValue)
Null-safe apply a new value, calculate the agg (e.g. min or max), and returns the new value. Nulls are skipped for evaluation!- Parameters:
newValue-- Returns:
- True if modified, otherwise false.
-
apply
public boolean apply(T newValue, boolean includeNulls)
Apply a new value, calculate the agg, and returns the new value. If you do includeNull, you MUST provide a null-safe comparator otherwise you will get a runtime NullPointerException.- Parameters:
newValue-includeNulls-- Returns:
- True if modified, otherwise false.
-
-