Class EditableChoiceParameterDefinition
- java.lang.Object
-
- hudson.model.ParameterDefinition
-
- hudson.model.SimpleParameterDefinition
-
- io.jenkins.plugins.editable_choice.EditableChoiceParameterDefinition
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<ParameterDefinition>
,Serializable
public class EditableChoiceParameterDefinition extends SimpleParameterDefinition
EditableChoiceParameterDefinition provides a string parameter with candidates.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EditableChoiceParameterDefinition.DescriptorImpl
Descriptor forEditableChoiceParameterDefinition
.-
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 EditableChoiceParameterDefinition(String name)
ctor.
-
Method Summary
-
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
-
EditableChoiceParameterDefinition
@DataBoundConstructor public EditableChoiceParameterDefinition(@NonNull String name)
ctor.- Parameters:
name
- the name of the parameter
-
-
Method Detail
-
withDescription
public EditableChoiceParameterDefinition withDescription(@CheckForNull String description)
- Parameters:
description
- the description- Returns:
- this instance
-
setChoices
@DataBoundSetter public void setChoices(@NonNull List<String> choices)
- Parameters:
choices
- choices used as candidates
-
choicesFromText
@NonNull public static List<String> choicesFromText(@NonNull String text)
- Parameters:
text
- choices delimited with new lines- Returns:
- choices
-
textFromChoices
public static String textFromChoices(@NonNull List<String> choices)
- Parameters:
choices
- choices- Returns:
- choices with delimited with new lines
-
setChoicesWithText
@DataBoundSetter public void setChoicesWithText(@NonNull String choicesWithText)
- Parameters:
choicesWithText
- choices with delimited with new lines
-
getChoicesWithText
@NonNull public String getChoicesWithText()
- Returns:
- choices with delimited with new lines
-
withChoices
public EditableChoiceParameterDefinition withChoices(List<String> choices)
- Parameters:
choices
- choices- Returns:
- this instance
-
setDefaultValue
@DataBoundSetter public void setDefaultValue(@CheckForNull String defaultValue)
- Parameters:
defaultValue
- the default value. The top choice is used ifnull
.
-
getDefaultValue
@Exported @CheckForNull public String getDefaultValue()
- Returns:
- the default value. The top choice is used if
null
.
-
setWithDefaultValue
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @DataBoundSetter public void setWithDefaultValue(@NonNull DefaultValue defaultValue)
Set the default value withDefaultValue
. Only for used with <f:optionalBlock>. UsesetDefaultValue(String)
instead.- Parameters:
defaultValue
- the default value withDefaultValue
-
getWithDefaultValue
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @CheckForNull public DefaultValue getWithDefaultValue()
Return the default value withDefaultValue
. Only for used with <f:optionalBlock>. UsegetDefaultValue()
instead.- Returns:
- the default value with
DefaultValue
-
withDefaultValue
public EditableChoiceParameterDefinition withDefaultValue(@CheckForNull String defaultValue)
- Parameters:
defaultValue
- the default value- Returns:
- this instance
-
setRestrict
@DataBoundSetter public void setRestrict(boolean restrict)
- Parameters:
restrict
- whether restrict value in choices
-
isRestrict
@Exported public boolean isRestrict()
- Returns:
- whether restrict value in choices
-
withRestrict
public EditableChoiceParameterDefinition withRestrict(boolean restrict)
- Parameters:
restrict
- whether restrict value in choices- Returns:
- this instance
-
setFilterConfig
@DataBoundSetter public void setFilterConfig(@CheckForNull FilterConfig filterConfig)
- Parameters:
filterConfig
- how to filter values for input.null
not to filter.
-
getFilterConfig
@CheckForNull public FilterConfig getFilterConfig()
- Returns:
- how to filter values for input.
null
not to filter.
-
withFilterConfig
public EditableChoiceParameterDefinition withFilterConfig(@CheckForNull FilterConfig filterConfig)
- Parameters:
filterConfig
- how to filter values for input- Returns:
- this instance
-
createDefaultValue
@CheckForNull public String createDefaultValue()
- Returns:
- the default value. the top most value if not configured.
-
getDefaultParameterValue
@CheckForNull public ParameterValue getDefaultParameterValue()
- Overrides:
getDefaultParameterValue
in classParameterDefinition
-
checkValue
protected boolean checkValue(@NonNull String value)
- Parameters:
value
- candidate input- Returns:
- whether the value is allowed (e.g. value in choices)
-
createValueCommon
protected ParameterValue createValueCommon(StringParameterValue value) throws IllegalArgumentException
- Parameters:
value
- the user input- Returns:
- the value of this parameter.
- Throws:
IllegalArgumentException
- The value is not in choices even not editable.
-
createValue
public ParameterValue createValue(org.kohsuke.stapler.StaplerRequest request, net.sf.json.JSONObject jo) throws IllegalArgumentException
- Specified by:
createValue
in classParameterDefinition
- Throws:
IllegalArgumentException
- The value is not in choices when restricted.
-
createValue
public ParameterValue createValue(String value) throws IllegalArgumentException
- Specified by:
createValue
in classSimpleParameterDefinition
- Throws:
IllegalArgumentException
- The value is not in choices when restricted.
-
-