Enum Class TypedProperty
- All Implemented Interfaces:
Serializable
,Comparable<TypedProperty>
,Constable
,nz.org.riskscape.engine.bind.ParameterProperty
Describes the type of value we expect for this parameter, i.e. what the parameter should bind against (Java type, not RiskScape type). This property can be used to bind a generic 'expression' parameter against a more specific type, e.g. it must be a number.
The idea is we want a simple, flexible set of types here. RiskScape types can be a
little too prescriptive (e.g. there's integer or there's floating - there is no 'number'),
and can confuse even expert users (e.g. relation(struct(foo: floating,...))
vs 'bookmark').
However, we don't want to make the types too Java-ry for the user either, e.g. we don't
want the user typing properties = UsgsShakemapBookmarkResolver
.
To try to do the 'right thing', RiskScape may infer (guess) properties for a parameter, e.g. "this thing looks like a number". Guessing a prescriptive type (e.g. integer) would be annoying, as the user might also want to enter floating values.
Ultimately, these typed parameters need to be converted back into a RiskScape expression, so that the value can be injected into pipeline DSL.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionThe parameter should accept either a bookmark or file.A user can explicitly state that a parameter takes an expression to avoid RiskScape inferring the wrong type.Used to explicitly state the parameter should only accept whole numbers, e.g.We don't really support binding against a JavaList
, so just bind lists as expressions.We don't support binding to just 'Number', but Double should work for anything that accepts either a float or integer RiskScape typeUsed to explicitly state the parameter should be a text string, e.g. -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<TypedProperty>
findBest
(Collection<nz.org.riskscape.engine.bind.ParameterProperty> properties) List<nz.org.riskscape.engine.bind.ParameterProperty>
Class<?>
boolean
isCompatible
(nz.org.riskscape.engine.bind.ParameterProperty that) static TypedProperty
Returns the enum constant of this class with the specified name.static TypedProperty[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
Methods inherited from interface nz.org.riskscape.engine.bind.ParameterProperty
getValueOr, hasKeyValuePair, implies, validate, withValue, withValue
-
Enum Constant Details
-
NUMERIC
We don't support binding to just 'Number', but Double should work for anything that accepts either a float or integer RiskScape type
-
INTEGER
Used to explicitly state the parameter should only accept whole numbers, e.g. 'year_built'. -
TEXT
Used to explicitly state the parameter should be a text string, e.g. 'foo'. In general, you'd be better off either usingBOOKMARK
or specifying the possible values as choices, rather than accepting any old text string, i.e. `param.example.choices = 'foo', 'bar', 'baz'`. One case for using text might be if you wanted to parameterize a column name or output filename -
LIST
We don't really support binding against a JavaList
, so just bind lists as expressions. UsingInputFieldProperty.MULTISELECT
orInputFieldProperty.CHECKBOX
instead should cover most cases in the UI where the user needs to enter a list of values, but this is here for completeness. -
BOOKMARK
The parameter should accept either a bookmark or file. TODO we don't differentiate between the two currently, but we might need to. You can't always use a bookmark in places that expect a filepath -
EXPRESSION
A user can explicitly state that a parameter takes an expression to avoid RiskScape inferring the wrong type. E.g. even though the default value is a numeric constant, the user still wants to be able to specify `exposure.road_width`.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
findBest
public static Optional<TypedProperty> findBest(Collection<nz.org.riskscape.engine.bind.ParameterProperty> properties) - Returns:
- the best TypedProperty to use (i.e. for binding), if any
-
isCompatible
public boolean isCompatible(nz.org.riskscape.engine.bind.ParameterProperty that) - Specified by:
isCompatible
in interfacenz.org.riskscape.engine.bind.ParameterProperty
-
getKeyword
- Specified by:
getKeyword
in interfacenz.org.riskscape.engine.bind.ParameterProperty
-
getParameterType
-
getImplied
- Specified by:
getImplied
in interfacenz.org.riskscape.engine.bind.ParameterProperty
-