Package net.sf.basedb.core.plugin
Class ParameterValuesWrapper
java.lang.Object
net.sf.basedb.core.plugin.ParameterValuesWrapper
- All Implemented Interfaces:
ParameterValues
A helper class that will wrap the parameter values from one job, one configuration
and one request object. The main use is to simplify reading parameter values that
may be located at different places. The
getValue(String)
and getValues(String)
methods will first check the request, if no parameter is present the job will be checked
and at last the configuration.
The setValue(String, ParameterType, Object)
and
setValues(String, ParameterType, List)
can be configured to write through to either the job or the configuration.
- Version:
- 2.4
- Author:
- nicklas
- Last modified
- $Date: 2019-02-26 11:10:15 +0100 (tis, 26 feb. 2019) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ParameterValues
private final ParameterValues
private final boolean
private final Request
-
Constructor Summary
ConstructorDescriptionParameterValuesWrapper
(Request request, ParameterValues job, ParameterValues config, boolean preferJob) -
Method Summary
Modifier and TypeMethodDescriptionint
getId()
Get the ID of either the job or the configuration, depending in thepreferJob
parameter that was set when creating this object.getJob()
Get the job that we are executing/configuring.Get the configuration that we are using/configuring.Get the PluginDefinition of either the job or the configuration, depending in thepreferJob
parameter that was set when creating this object.<T> T
Get the value of the parameter with the specified name.<T> List<T>
Get the values of the parameter with the specified name.<T> void
setValue
(String name, ParameterType<T> type, T value) Set the value on either the job or configuration, depending in thepreferJob
parameter that was set when creating this object.<T> void
setValues
(String name, ParameterType<T> type, List<T> values) Set the value on either the job or configuration, depending in thepreferJob
parameter that was set when creating this object.
-
Field Details
-
request
-
job
-
config
-
preferJob
private final boolean preferJob
-
-
Constructor Details
-
ParameterValuesWrapper
public ParameterValuesWrapper(Request request, ParameterValues job, ParameterValues config, boolean preferJob)
-
-
Method Details
-
getId
public int getId()Get the ID of either the job or the configuration, depending in thepreferJob
parameter that was set when creating this object.- Specified by:
getId
in interfaceParameterValues
- Returns:
- The ID of the job or configuration or 0 if there is none
-
getJob
Description copied from interface:ParameterValues
Get the job that we are executing/configuring.- Specified by:
getJob
in interfaceParameterValues
- Returns:
- A Job or null if not known
-
getPluginConfiguration
Description copied from interface:ParameterValues
Get the configuration that we are using/configuring.- Specified by:
getPluginConfiguration
in interfaceParameterValues
- Returns:
- A PluginConfiguration or null if not known
-
getPluginDefinition
Get the PluginDefinition of either the job or the configuration, depending in thepreferJob
parameter that was set when creating this object.- Specified by:
getPluginDefinition
in interfaceParameterValues
- Returns:
- The PluginDefinition of the job or configuration or null if there is none
-
getValue
Get the value of the parameter with the specified name. This method first looks for a value in the Request object. If not found, it looks in the job object, and at last in the configuration object.- Specified by:
getValue
in interfaceParameterValues
- Parameters:
name
- the name of the parameter- Returns:
- The value of the specified parameter
- Throws:
PermissionDeniedException
- If the logged in user doesn't have permission to read the valueBaseException
- If there is another error
-
getValues
Get the values of the parameter with the specified name. This method first looks for a value in the Request object. If not found, it looks in the job object, and at last in the configuration object.- Specified by:
getValues
in interfaceParameterValues
- Parameters:
name
- The name of the parameter- Returns:
- The value of the specified parameter
- Throws:
PermissionDeniedException
- If the logged in user doesn't have permission to read the valuesBaseException
- If there is another error
-
setValue
public <T> void setValue(String name, ParameterType<T> type, T value) throws PermissionDeniedException, InvalidDataException, BaseException Set the value on either the job or configuration, depending in thepreferJob
parameter that was set when creating this object.- Specified by:
setValue
in interfaceParameterValues
- Parameters:
name
- The name of the parametertype
- The type of the valuevalue
- The value to be set- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the value is invalid according to the settings in the typeBaseException
- If there is another error
-
setValues
public <T> void setValues(String name, ParameterType<T> type, List<T> values) throws PermissionDeniedException, InvalidDataException, BaseException Set the value on either the job or configuration, depending in thepreferJob
parameter that was set when creating this object.- Specified by:
setValues
in interfaceParameterValues
- Parameters:
name
- The name of the parametertype
- The type of the valuevalues
- A list containing the values- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If any of the values is invalid according to the settings in the typeBaseException
- If there is another error
-