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.ParameterDescriptorNested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringUsed to split values when scripts return values like A=2, B=3.protected static final StringConstant used to add the build in the environment variables map.protected static final StringConstant used to add the parameter name in the environment variables map.protected static final StringConstant used to add the project in the environment variables map.protected final ScriptScript used to render the parameter.protected static final StringUsed 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_SELECTFields inherited from class hudson.model.ParameterDefinition
LIST -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractScriptableParameter(String name, String description, String randomName, Script script) Inherited constructor.protectedAbstractScriptableParameter(String name, String description, Script script) Deprecated.see JENKINS-32149 -
Method Summary
Modifier and TypeMethodDescriptionprotected AbstractItemgetChoices(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.intGet the number of visible items in the select.Methods inherited from class org.biouno.unochoice.AbstractUnoChoiceParameter
createValue, createValue, getChoiceType, getDescriptor, getRandomNameMethods inherited from class hudson.model.SimpleParameterDefinition
createValue, createValueMethods inherited from class hudson.model.ParameterDefinition
all, copyWithDefaultValue, createValue, createValue, 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:ScriptableParameterEvaluates a script and returns its result as a Map. List values are automatically handled and converted to Maps too.- Specified by:
getChoicesin interfaceScriptableParameter<Map<Object,Object>> - Parameters:
parameters- parameters- Returns:
- script result as Map
-
getChoicesAsString
-
getChoicesAsString
-
getDefaultParameterValue
- Overrides:
getDefaultParameterValuein 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
-