public abstract class BaseParameter<T> extends Object implements Parameter<T>
Parameter
, providing support
for multiple default parameter names, and a default value if
no parameter is specified.
Modifier and Type | Field and Description |
---|---|
protected boolean |
shouldValidate |
Modifier | Constructor and Description |
---|---|
protected |
BaseParameter(List<String> names,
String defaultValue) |
protected |
BaseParameter(String[] names,
String defaultValue) |
protected |
BaseParameter(String name,
String defaultValue) |
Modifier and Type | Method and Description |
---|---|
void |
addParameterAlias(String name)
Deprecated.
since 3.1: this class is not thread safe and should not be mutated
|
protected abstract T |
findObject(String paramValue,
MacroExecutionContext ctx)
Responsible for converting a macro parameter string value to its proper object representation (say "1" to new Integer(1))
|
T |
findValue(MacroExecutionContext ctx)
Attempts to find the value from the specified
MacroExecutionContext object. |
String |
getDefaultValue()
Returns the default value for this parameter if no match is found in
the context.
|
protected String |
getParameter(Map<String,String> params,
List names,
String defaultValue)
Returns the literal value of the parameter in the specified
Map , using the specified List for names and
aliases and the specified default value. |
String |
getParameterValue(Map<String,String> params)
Returns the literal value of the parameter, or the default value if
none is present.
|
void |
setDefaultValue(String defaultValue)
Deprecated.
since 3.1: this class is not thread safe and should not be mutated
|
void |
setParameterNames(String[] names)
Deprecated.
since 3.1: this class is not thread safe and should not be mutated
|
void |
setValidate(boolean shouldValidate)
Sets whether this parameter should attempt to validate its values.
|
@Deprecated public final void addParameterAlias(String name)
name
- another name for the parameter recognized by this object@Deprecated public final void setParameterNames(String[] names)
names
- the names of the parameter to recognize@Deprecated public final void setDefaultValue(String defaultValue)
defaultValue
- the default value for this parameterpublic final String getDefaultValue()
protected final String getParameter(Map<String,String> params, List names, String defaultValue)
Map
, using the specified List
for names and
aliases and the specified default value.params
- the Map
of parameters to searchnames
- the parameter names to look fordefaultValue
- the default value to return if no match is foundpublic final String getParameterValue(Map<String,String> params)
params
- the Map
of parameters to searchpublic final void setValidate(boolean shouldValidate)
Parameter
setValidate
in interface Parameter<T>
shouldValidate
- true if this parameter should attempt to validatepublic final T findValue(MacroExecutionContext ctx) throws ParameterException
Parameter
MacroExecutionContext
object.findValue
in interface Parameter<T>
ctx
- The execution context for the macro.ParameterException
- if there was a problem while processing the parameter.protected abstract T findObject(String paramValue, MacroExecutionContext ctx) throws ParameterException
ParameterException
Copyright © 2003–2020 Atlassian. All rights reserved.