Package nz.org.riskscape.engine.bind
Class DefaultBindingContext
java.lang.Object
nz.org.riskscape.engine.bind.DefaultBindingContext
- All Implemented Interfaces:
nz.org.riskscape.engine.bind.BindingContext
public class DefaultBindingContext
extends Object
implements nz.org.riskscape.engine.bind.BindingContext
Various bits of dependency that might be required for parameter binding
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDefaultBindingContext
(nz.org.riskscape.engine.Project project, nz.org.riskscape.engine.rl.RealizationContext context) DefaultBindingContext
(nz.org.riskscape.engine.Project project, nz.org.riskscape.engine.rl.RealizationContext context, Path tempDir) -
Method Summary
Modifier and TypeMethodDescription<T> nz.org.riskscape.problem.ResultOrProblems<T>
Bind the given value to the required typeDeprecated.Optional<nz.org.riskscape.engine.bind.ParameterBinder>
List<nz.org.riskscape.engine.bind.ParameterBinder>
nz.org.riskscape.engine.Engine
nz.org.riskscape.engine.Project
nz.org.riskscape.engine.rl.RealizationContext
URI that any relative file paths should be resolved against.nz.org.riskscape.engine.SRIDSet
void
setBinders
(List<nz.org.riskscape.engine.bind.ParameterBinder> binders) void
setProject
(nz.org.riskscape.engine.Project project) void
setSridSet
(nz.org.riskscape.engine.SRIDSet sridSet) void
validateBoundParameters
(List<nz.org.riskscape.engine.bind.Parameter> parameters, Map<String, List<?>> boundParameters) Validates a map of already bound parameters against a models set of declared parameters to check their arity and type.withNewRelativeTo
(URI newRelativeTo) Get a new BindingContext with relativeTo Uri set to newRelativeTo.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface nz.org.riskscape.engine.bind.BindingContext
bind, bindAll, bindAll
-
Field Details
-
DEFAULT_BINDERS
-
-
Constructor Details
-
DefaultBindingContext
public DefaultBindingContext(nz.org.riskscape.engine.Project project, nz.org.riskscape.engine.rl.RealizationContext context) -
DefaultBindingContext
public DefaultBindingContext(nz.org.riskscape.engine.Project project, nz.org.riskscape.engine.rl.RealizationContext context, Path tempDir)
-
-
Method Details
-
withNewRelativeTo
Get a new BindingContext with relativeTo Uri set to newRelativeTo.
- Specified by:
withNewRelativeTo
in interfacenz.org.riskscape.engine.bind.BindingContext
- Parameters:
newRelativeTo
- new base URI to resolve relative files against- Returns:
- binding context with relative to set to newRelativeTo
-
getBinder
public Optional<nz.org.riskscape.engine.bind.ParameterBinder> getBinder(Class<?> fromType, Class<?> toType) - Specified by:
getBinder
in interfacenz.org.riskscape.engine.bind.BindingContext
- Returns:
- a
ParameterBinder
for the given java type in modelParameter.
-
bind
Bind the given value to the required type
- Specified by:
bind
in interfacenz.org.riskscape.engine.bind.BindingContext
- Returns:
- a bound value, or a failed result describing why the value couldn't be converted
- Throws:
nz.org.riskscape.engine.bind.NoBindingAvailableException
- if there wasn't a binder available. This is thrown, rather than returned in result or problems as this is a system error rather than a user error
-
bind
Deprecated.- Specified by:
bind
in interfacenz.org.riskscape.engine.bind.BindingContext
-
validateBoundParameters
public void validateBoundParameters(List<nz.org.riskscape.engine.bind.Parameter> parameters, Map<String, List<?>> boundParameters) throws nz.org.riskscape.engine.bind.InvalidBoundParametersExceptionValidates a map of already bound parameters against a models set of declared parameters to check their arity and type.
- Specified by:
validateBoundParameters
in interfacenz.org.riskscape.engine.bind.BindingContext
- Throws:
nz.org.riskscape.engine.bind.InvalidBoundParametersException
- if there are problems with number or type of a parameter
-
getEngine
public nz.org.riskscape.engine.Engine getEngine()- Specified by:
getEngine
in interfacenz.org.riskscape.engine.bind.BindingContext
-
getTempDirectory
- Specified by:
getTempDirectory
in interfacenz.org.riskscape.engine.bind.BindingContext
-
getBinders
-
setBinders
-
getSridSet
public nz.org.riskscape.engine.SRIDSet getSridSet() -
setSridSet
public void setSridSet(nz.org.riskscape.engine.SRIDSet sridSet) -
getProject
public nz.org.riskscape.engine.Project getProject()- Specified by:
getProject
in interfacenz.org.riskscape.engine.bind.BindingContext
-
setProject
public void setProject(nz.org.riskscape.engine.Project project) -
getRelativeTo
URI that any relative file paths should be resolved against.
- Specified by:
getRelativeTo
in interfacenz.org.riskscape.engine.bind.BindingContext
-
getRealizationContext
public nz.org.riskscape.engine.rl.RealizationContext getRealizationContext()- Specified by:
getRealizationContext
in interfacenz.org.riskscape.engine.bind.BindingContext
-