Package org.biouno.unochoice
Class AbstractScriptableParameter
java.lang.Object
hudson.model.ParameterDefinition
hudson.model.SimpleParameterDefinition
org.biouno.unochoice.AbstractUnoChoiceParameter
org.biouno.unochoice.AbstractScriptableParameter
- All Implemented Interfaces:
ExtensionPoint
,Describable<ParameterDefinition>
,Serializable
,ScriptableParameter<Map<Object,
,Object>> UnoChoiceParameter
- Direct Known Subclasses:
AbstractCascadableParameter
,ChoiceParameter
public abstract class AbstractScriptableParameter
extends AbstractUnoChoiceParameter
implements ScriptableParameter<Map<Object,Object>>
Base class for parameters with scripts.
- Since:
- 0.20
- Author:
- Bruno P. Kinoshita
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class hudson.model.ParameterDefinition
ParameterDefinition.ParameterDescriptor
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
Used to split values when scripts return values like A=2, B=3.protected static final String
Constant used to add the build in the environment variables map.protected static final String
Constant used to add the parameter name in the environment variables map.protected static final String
Constant used to add the project in the environment variables map.protected final Script
Script used to render the parameter.protected static final String
Used to split values that come from the UI via Ajax POST'sFields inherited from class org.biouno.unochoice.AbstractUnoChoiceParameter
DEFAULT_MAX_VISIBLE_ITEM_COUNT, ELEMENT_TYPE_FORMATTED_HIDDEN_HTML, ELEMENT_TYPE_FORMATTED_HTML, ELEMENT_TYPE_ORDERED_LIST, ELEMENT_TYPE_TEXT_BOX, ELEMENT_TYPE_UNORDERED_LIST, LOGGER, PARAMETER_TYPE_CHECK_BOX, PARAMETER_TYPE_MULTI_SELECT, PARAMETER_TYPE_RADIO, PARAMETER_TYPE_SINGLE_SELECT
Fields inherited from class hudson.model.ParameterDefinition
LIST
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractScriptableParameter
(String name, String description, String randomName, Script script) Inherited constructor.protected
AbstractScriptableParameter
(String name, String description, Script script) Deprecated.see JENKINS-32149 -
Method Summary
Modifier and TypeMethodDescriptionprotected AbstractItem
getChoices
(Map<Object, Object> parameters) Evaluates a script and returns its result as a Map.getChoicesAsString
(Map<Object, Object> parameters) Gets the current parameters, be it before or after other referenced parameters triggered an update.Gets the script.int
Get the number of visible items in the select.Methods inherited from class org.biouno.unochoice.AbstractUnoChoiceParameter
all, createValue, createValue, getChoiceType, getDescriptor, getRandomName
Methods inherited from class hudson.model.SimpleParameterDefinition
createValue, createValue
Methods inherited from class hudson.model.ParameterDefinition
copyWithDefaultValue, equals, getDescription, getFormattedDescription, getName, getType, hashCode, isValid, setDescription
-
Field Details
-
SEPARATOR
Used to split values that come from the UI via Ajax POST's- See Also:
-
EQUALS
Used to split values when scripts return values like A=2, B=3.- See Also:
-
JENKINS_PROJECT_VARIABLE_NAME
Constant used to add the project in the environment variables map.- See Also:
-
JENKINS_BUILD_VARIABLE_NAME
Constant used to add the build in the environment variables map.- See Also:
-
JENKINS_PARAMETER_VARIABLE_NAME
Constant used to add the parameter name in the environment variables map.- See Also:
-
script
Script used to render the parameter.
-
-
Constructor Details
-
AbstractScriptableParameter
Deprecated.see JENKINS-32149Inherited constructor.- Parameters:
name
- namedescription
- descriptionscript
- script used to generate the list of parameter values
-
AbstractScriptableParameter
protected AbstractScriptableParameter(String name, String description, String randomName, Script script) Inherited constructor.- Parameters:
name
- namedescription
- descriptionrandomName
- parameter random generated name (uuid)script
- script used to generate the list of parameter values
-
-
Method Details
-
detectProject
-
getScript
Gets the script.- Returns:
- the script
-
getParameters
Gets the current parameters, be it before or after other referenced parameters triggered an update. Populates parameters common to all evaluations, such as jenkinsProject, which is the current Jenkins project.- Returns:
- the current parameters with pre-populated defaults
-
getChoices
-
getChoices
Description copied from interface:ScriptableParameter
Evaluates a script and returns its result as a Map. List values are automatically handled and converted to Maps too.- Specified by:
getChoices
in interfaceScriptableParameter<Map<Object,
Object>> - Parameters:
parameters
- parameters- Returns:
- script result as Map
-
getChoicesAsString
-
getChoicesAsString
-
getDefaultParameterValue
- Overrides:
getDefaultParameterValue
in classParameterDefinition
-
getVisibleItemCount
public int getVisibleItemCount()Get the number of visible items in the select.- Returns:
- the number of choices or, if it is higher than the default, then it returns the default maximum value
-