Interface ParameterBinder
- All Superinterfaces:
Identified
Interface for a class that can convert a string in to an object of a particular type
A note on deprecation and where this code is going:
binding is to become detached from the parameter - the parameter is just context that we'll probably wrap around any binding problems via the binding context bind method
new binders should not implement the deprecated methods and instead use the NewBaseBinder class, which will take care of implementing those deprecated methods in a consistent way
-
Method Summary
Modifier and TypeMethodDescriptionbind
(BindingContext context, Parameter modelParameter, String value) Deprecated.<T> ResultOrProblems<T>
bindValue
(BindingContext context, Object value, Class<T> destinationType) Convert a value in to an object of a desired type.boolean
static boolean
validateExistingFileOrUri
(Parameter param, String value) Useful pre-emptive validation for values before they go in to geotools to check whether they look openable.static <T extends Identified>
TwrapFailedObject
(Parameter parameter, String id, IdentifiedCollection<T> collection) Helper method for wrapping a lookup to wrap aFailedObjectException
in aParameterBindingException
static <T extends Identified>
TwrapLookup
(Parameter parameter, String id, BindingContext context, Class<T> identifedClass) Helper method for wrapping a lookup to wrap it in aParameterBindingException
Methods inherited from interface nz.org.riskscape.engine.Identified
getId, getIdentifiedClass
-
Method Details
-
validateExistingFileOrUri
Useful pre-emptive validation for values before they go in to geotools to check whether they look openable.
-
wrapFailedObject
static <T extends Identified> T wrapFailedObject(Parameter parameter, String id, IdentifiedCollection<T> collection) Helper method for wrapping a lookup to wrap a
FailedObjectException
in aParameterBindingException
-
wrapLookup
static <T extends Identified> T wrapLookup(Parameter parameter, String id, BindingContext context, Class<T> identifedClass) Helper method for wrapping a lookup to wrap it in a
ParameterBindingException
-
canBind
- Returns:
- true if this binder can convert an object of sourceType to destinationType
-
bind
@Deprecated Object bind(BindingContext context, Parameter modelParameter, String value) throws ParameterBindingException Deprecated.usebindValue(BindingContext, Object, Class)
instead. Older code can use the CompatBinder to as a simple way of avoiding the deprecation warning and conforming to the new APIConvert a string in to an object of a desired type.
- Parameters:
context
- dependencies etc that can be used to aid conversionmodelParameter
- describes the parameter including the desired java type. The implementation must return an object for whichmodelParameter.getType().isInstanceOf(object)
returns truevalue
- the string to convert- Returns:
- a converted object
- Throws:
ParameterBindingException
- if there was an error binding which the user might be able to fix
-
bindValue
Convert a value in to an object of a desired type. See
for more detail on this new API. Note that the <code>destinationType</code> arg now follows the <code>value</code>, which matches the canBind method and follows a from -> to order</p>
- Parameters:
context
- dependencies etc that can be used to aid conversionvalue
- an object to convert, must be of a type thatcanBind
says it supportsdestinationType
- a type to convert the value to, must be of a type thatcanBind
says it supports- Returns:
- a converted object, or problems detailing why the value could not be converted
-
bindValue(BindingContext, Object, Class)
instead.