Class ExtensibleChoiceParameterDefinition
- java.lang.Object
-
- hudson.model.ParameterDefinition
-
- hudson.model.SimpleParameterDefinition
-
- jp.ikedam.jenkins.plugins.extensible_choice_parameter.ExtensibleChoiceParameterDefinition
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<ParameterDefinition>
,Serializable
public class ExtensibleChoiceParameterDefinition extends SimpleParameterDefinition
Provides a choice parameter whose choices can be extended using Extension Points.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ExtensibleChoiceParameterDefinition.DescriptorImpl
The internal class to work with views.static class
ExtensibleChoiceParameterDefinition.DescriptorVisibilityFilterImpl
static class
ExtensibleChoiceParameterDefinition.EditableType
How to display choices for input values-
Nested classes/interfaces inherited from class hudson.model.ParameterDefinition
ParameterDefinition.ParameterDescriptor
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
-
Fields inherited from class hudson.model.ParameterDefinition
LIST
-
-
Constructor Summary
Constructors Constructor Description ExtensibleChoiceParameterDefinition(String name, ChoiceListProvider choiceListProvider, boolean editable, String description)
Constructor instantiating with parameters in the configuration page.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ParameterValue
createValue(String value)
Decide a value of this parameter from the user input.ParameterValue
createValue(org.kohsuke.stapler.StaplerRequest request, net.sf.json.JSONObject jo)
Decide a value of this parameter from the user input.protected ParameterValue
createValueCommon(StringParameterValue value)
Test passed ParameterValue and return.List<String>
getChoiceList()
Return choices available for this parameter.ChoiceListProvider
getChoiceListProvider()
The choice provider the user specified.List<String>
getChoicesForRestApi()
Expose choices to REST web API Expose choices to trigger builds from programs, in the same way to built-in choice parameters.ParameterValue
getDefaultParameterValue()
Returns the default value of this parameter.ExtensibleChoiceParameterDefinition.EditableType
getEditableType()
ChoiceListProvider
getEnabledChoiceListProvider()
static Pattern
getNamePattern()
Deprecated.boolean
isEditable()
Is this parameter value can be set to a value not in the choices?void
setEditableType(ExtensibleChoiceParameterDefinition.EditableType editableType)
-
Methods inherited from class hudson.model.SimpleParameterDefinition
createValue, createValue
-
Methods inherited from class hudson.model.ParameterDefinition
all, copyWithDefaultValue, equals, getDescription, getDescriptor, getFormattedDescription, getName, getType, hashCode, isValid, setDescription
-
-
-
-
Constructor Detail
-
ExtensibleChoiceParameterDefinition
@DataBoundConstructor public ExtensibleChoiceParameterDefinition(String name, ChoiceListProvider choiceListProvider, boolean editable, String description)
Constructor instantiating with parameters in the configuration page. When instantiating from the saved configuration, the object is directly serialized with XStream, and no constructor is used.- Parameters:
name
- the name of this parameter (used as a variable name).choiceListProvider
- the choice providereditable
- whether this parameter can be a value not in choices.description
- the description of this parameter. Used only for the convenience of users.
-
-
Method Detail
-
getNamePattern
@Deprecated public static Pattern getNamePattern()
Deprecated.Deprecated
-
isEditable
public boolean isEditable()
Is this parameter value can be set to a value not in the choices?- Returns:
- whether this parameter is editable.
-
getEditableType
@Nonnull public ExtensibleChoiceParameterDefinition.EditableType getEditableType()
- Returns:
- How to display choices for input values
-
setEditableType
@DataBoundSetter public void setEditableType(ExtensibleChoiceParameterDefinition.EditableType editableType)
- Parameters:
editableType
- How to display choices for input values
-
getChoiceListProvider
public ChoiceListProvider getChoiceListProvider()
The choice provider the user specified.- Returns:
- choice provider.
-
getEnabledChoiceListProvider
public ChoiceListProvider getEnabledChoiceListProvider()
- Returns:
- choice provider only when it's enabled
- See Also:
ExtensibleChoiceParameterDefinition.DescriptorImpl.isProviderEnabled(Descriptor)
-
getChoiceList
public List<String> getChoiceList()
Return choices available for this parameter.- Returns:
- list of choices. never null.
-
getChoicesForRestApi
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @Exported(name="choices") public List<String> getChoicesForRestApi()
Expose choices to REST web API Expose choices to trigger builds from programs, in the same way to built-in choice parameters. Only users with the Item/BUILD permission can access it.- Returns:
- the list of choices.
null
if no Item/Build permission. - Since:
- 1.7.0
-
createValueCommon
protected ParameterValue createValueCommon(StringParameterValue value)
Test passed ParameterValue and return. Common processing of createValue- Parameters:
value
- a value to test.- Returns:
- a value tested. same with value.
-
createValue
public ParameterValue createValue(org.kohsuke.stapler.StaplerRequest request, net.sf.json.JSONObject jo)
Decide a value of this parameter from the user input.- Specified by:
createValue
in classParameterDefinition
- Parameters:
request
-jo
- the user input- Returns:
- the value of this parameter.
- See Also:
ParameterDefinition.createValue(org.kohsuke.stapler.StaplerRequest, net.sf.json.JSONObject)
-
createValue
public ParameterValue createValue(String value) throws IllegalArgumentException
Decide a value of this parameter from the user input.- Specified by:
createValue
in classSimpleParameterDefinition
- Parameters:
value
- the user input- Returns:
- the value of this parameter.
- Throws:
IllegalArgumentException
- The value is not in choices even the field is not editable.- See Also:
SimpleParameterDefinition.createValue(java.lang.String)
-
getDefaultParameterValue
public ParameterValue getDefaultParameterValue()
Returns the default value of this parameter. If not specified by the provider, the first value in the choice is used. returns null if no choice list is defined.- Overrides:
getDefaultParameterValue
in classParameterDefinition
- Returns:
- the default value of this parameter.
- See Also:
ParameterDefinition.getDefaultParameterValue()
-
-