Package nz.org.riskscape.engine.bind
Class KeyValueProperty<T>
java.lang.Object
nz.org.riskscape.engine.bind.KeyValueProperty<T>
- All Implemented Interfaces:
nz.org.riskscape.engine.bind.ParameterProperty
public class KeyValueProperty<T>
extends Object
implements nz.org.riskscape.engine.bind.ParameterProperty
Stores a property that represents a key-value pair, e.g. min: 0
. Most
ParameterProperty are enum-based, however, a KeyValueProperty needs to be an
object, because it takes a configurable value. The idea is we can create the
property with a placeholder value (e.g. min: -Infinity
), then swap out the
placeholder later with the user's actual config (e.g. min: 0
)
-
Constructor Summary
ConstructorDescriptionKeyValueProperty
(String key, Class<T> bindType) Construct a new KeyValueProperty with no default value.KeyValueProperty
(String key, T value) KeyValueProperty
(String keyword, T value, List<nz.org.riskscape.engine.bind.ParameterProperty> implied, Function<nz.org.riskscape.engine.bind.ParameterProperty, Boolean> checkCompatible, BiFunction<KeyValueProperty<T>, Object, List<nz.org.riskscape.problem.Problem>> checkValid, BiFunction<nz.org.riskscape.engine.bind.BindingContext, Object, nz.org.riskscape.problem.ResultOrProblems<T>> valueBinder) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
boolean
BiFunction<KeyValueProperty<T>,
Object, List<nz.org.riskscape.problem.Problem>> List<nz.org.riskscape.engine.bind.ParameterProperty>
getValue()
Optional<?>
int
hashCode()
boolean
boolean
isCompatible
(nz.org.riskscape.engine.bind.ParameterProperty other) static KeyValueProperty<Double>
Returns a numeric KeyValueProperty with a placeholder value.toString()
List<nz.org.riskscape.problem.Problem>
withCompatibility
(Function<nz.org.riskscape.engine.bind.ParameterProperty, Boolean> isCompatible) withImplied
(nz.org.riskscape.engine.bind.ParameterProperty... newImplied) withValidation
(BiFunction<KeyValueProperty<T>, Object, List<nz.org.riskscape.problem.Problem>> newValidation) nz.org.riskscape.engine.bind.ParameterProperty
nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.bind.ParameterProperty>
withValueBinding
(BiFunction<nz.org.riskscape.engine.bind.BindingContext, Object, nz.org.riskscape.problem.ResultOrProblems<T>> newBindValue) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface nz.org.riskscape.engine.bind.ParameterProperty
implies
-
Constructor Details
-
KeyValueProperty
Construct a new KeyValueProperty with no default value.
- Parameters:
bindType
- the expected type of values - will be used to bind any value that is given to this property
-
KeyValueProperty
-
KeyValueProperty
public KeyValueProperty(String keyword, T value, List<nz.org.riskscape.engine.bind.ParameterProperty> implied, Function<nz.org.riskscape.engine.bind.ParameterProperty, Boolean> checkCompatible, BiFunction<KeyValueProperty<T>, Object, List<nz.org.riskscape.problem.Problem>> checkValid, BiFunction<nz.org.riskscape.engine.bind.BindingContext, Object, nz.org.riskscape.problem.ResultOrProblems<T>> valueBinder)
-
-
Method Details
-
numeric
Returns a numeric KeyValueProperty with a placeholder value. Note that we work with Double for Numeric values, mostly because we don't support binding to Numbers.
-
isCompatible
public boolean isCompatible(nz.org.riskscape.engine.bind.ParameterProperty other) - Specified by:
isCompatible
in interfacenz.org.riskscape.engine.bind.ParameterProperty
-
getValueOr
- Specified by:
getValueOr
in interfacenz.org.riskscape.engine.bind.ParameterProperty
-
validate
public List<nz.org.riskscape.problem.Problem> validate(nz.org.riskscape.engine.bind.BindingContext context, Object bound) - Specified by:
validate
in interfacenz.org.riskscape.engine.bind.ParameterProperty
-
withValue
- Specified by:
withValue
in interfacenz.org.riskscape.engine.bind.ParameterProperty
-
withValue
public nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.bind.ParameterProperty> withValue(nz.org.riskscape.engine.bind.BindingContext context, Object newValue) - Specified by:
withValue
in interfacenz.org.riskscape.engine.bind.ParameterProperty
-
withImplied
public KeyValueProperty<T> withImplied(nz.org.riskscape.engine.bind.ParameterProperty... newImplied) -
withCompatibility
public KeyValueProperty<T> withCompatibility(Function<nz.org.riskscape.engine.bind.ParameterProperty, Boolean> isCompatible) -
withValidation
public KeyValueProperty<T> withValidation(BiFunction<KeyValueProperty<T>, Object, List<nz.org.riskscape.problem.Problem>> newValidation) -
withValueBinding
public KeyValueProperty<T> withValueBinding(BiFunction<nz.org.riskscape.engine.bind.BindingContext, Object, nz.org.riskscape.problem.ResultOrProblems<T>> newBindValue) -
toString
-
hasKeyValuePair
public boolean hasKeyValuePair()- Specified by:
hasKeyValuePair
in interfacenz.org.riskscape.engine.bind.ParameterProperty
-
equals
-
canEqual
-
hashCode
public int hashCode() -
getKeyword
- Specified by:
getKeyword
in interfacenz.org.riskscape.engine.bind.ParameterProperty
-
getValue
-
getImplied
- Specified by:
getImplied
in interfacenz.org.riskscape.engine.bind.ParameterProperty
-
getCheckCompatible
-
getCheckValid
public BiFunction<KeyValueProperty<T>,Object, getCheckValid()List<nz.org.riskscape.problem.Problem>>
-