java.lang.Object
org.elasticsearch.cluster.metadata.ResettableValue<T>
- Type Parameters:
T
-
This class holds a value of type @{param T} that can be in one of 3 states:
- It has a concrete value, or
- It is missing, or
- It is meant to reset any other when it is composed with it.
It is mainly used in template composition to capture the case when the user wished to reset any previous values.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ResettableValue
<T> create
(T value) Wraps a value, if the value is null, it returnsundefined()
boolean
get()
int
hashCode()
static ToXContent.Params
hideResetValues
(ToXContent.Params params) boolean
<U> ResettableValue
<U> <U> U
Gets the value and applies the function when the value is not null.static <T> ResettableValue
<T> merge
(ResettableValue<T> initial, ResettableValue<T> update, BiFunction<T, T, T> mergeFunction) Ιt merges the values of the ResettableValue's when they are defined using the provided mergeFunction.static <T> ResettableValue
<T> reset()
static boolean
boolean
toString()
toXContent
(XContentBuilder builder, ToXContent.Params params, String field) <U> XContentBuilder
toXContent
(XContentBuilder builder, ToXContent.Params params, String field, Function<T, U> transformValue) static <T> ResettableValue
<T>
-
Method Details
-
reset
- Returns:
- the reset state, meaning that this value is explicitly requested to be reset
-
undefined
- Returns:
- the undefined state, meaning that this value has not been specified
-
create
Wraps a value, if the value is null, it returnsundefined()
-
shouldReset
public boolean shouldReset()- Returns:
- true if the state of this is reset
-
isDefined
public boolean isDefined()- Returns:
- true when the value is defined, either with a concrete value or reset.
-
get
- Returns:
- the concrete value or null if it is in undefined or reset states.
-
mapAndGet
Gets the value and applies the function when the value is not null. Slightly more efficient thanthis.map(f).get()
. -
map
-
merge
public static <T> ResettableValue<T> merge(ResettableValue<T> initial, ResettableValue<T> update, BiFunction<T, T, T> mergeFunction) Ιt merges the values of the ResettableValue's when they are defined using the provided mergeFunction. -
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params, String field) throws IOException - Throws:
IOException
-
toXContent
public <U> XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params, String field, Function<T, U> transformValue) throws IOException- Throws:
IOException
-
shouldDisplayResetValue
-
hideResetValues
-
equals
-
hashCode
public int hashCode() -
toString
-