Class BaseParameter<T>
java.lang.Object
com.atlassian.confluence.macro.params.BaseParameter<T>
- All Implemented Interfaces:
Parameter<T>
- Direct Known Subclasses:
BooleanQueryFactoryParameter
,MaxResultsParameter
,MultiValueParameter
,SearchSortParameter
A base implementation of
Parameter
, providing support
for multiple default parameter names, and a default value if
no parameter is specified.
- Since:
- 2.9
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BaseParameter
(String[] names, String defaultValue) protected
BaseParameter
(String name, String defaultValue) protected
BaseParameter
(List<String> names, String defaultValue) -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addParameterAlias
(String name) Deprecated.since 3.1: this class is not thread safe and should not be mutatedprotected 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))final T
Attempts to find the value from the specifiedMacroExecutionContext
object.final String
Returns the default value for this parameter if no match is found in the context.protected final String
Returns the literal value of the parameter in the specifiedMap
, using the specifiedList
for names and aliases and the specified default value.final String
getParameterValue
(Map<String, String> params) Returns the literal value of the parameter, or the default value if none is present.final void
setDefaultValue
(String defaultValue) Deprecated.since 3.1: this class is not thread safe and should not be mutatedfinal void
setParameterNames
(String[] names) Deprecated.since 3.1: this class is not thread safe and should not be mutatedfinal void
setValidate
(boolean shouldValidate) Sets whether this parameter should attempt to validate its values.
-
Field Details
-
shouldValidate
protected boolean shouldValidate
-
-
Constructor Details
-
BaseParameter
-
BaseParameter
-
BaseParameter
-
-
Method Details
-
addParameterAlias
Deprecated.since 3.1: this class is not thread safe and should not be mutatedAdds the specified String as an alias to the default name of this parameter.- Parameters:
name
- another name for the parameter recognized by this object
-
setParameterNames
Deprecated.since 3.1: this class is not thread safe and should not be mutatedSets the specified String array as the names by which to recognize this parameter.- Parameters:
names
- the names of the parameter to recognize
-
setDefaultValue
Deprecated.since 3.1: this class is not thread safe and should not be mutatedSets the default value to be returned for this parameter if no match is found in the context.- Parameters:
defaultValue
- the default value for this parameter
-
getDefaultValue
Returns the default value for this parameter if no match is found in the context.- Returns:
- the default value for this parameter
-
getParameter
Returns the literal value of the parameter in the specifiedMap
, using the specifiedList
for names and aliases and the specified default value.- Parameters:
params
- theMap
of parameters to searchnames
- the parameter names to look fordefaultValue
- the default value to return if no match is found- Returns:
- the parameter value, or the default if none is found
-
getParameterValue
Returns the literal value of the parameter, or the default value if none is present.- Parameters:
params
- theMap
of parameters to search- Returns:
- the literal value of the parameter
-
setValidate
public final void setValidate(boolean shouldValidate) Description copied from interface:Parameter
Sets whether this parameter should attempt to validate its values.- Specified by:
setValidate
in interfaceParameter<T>
- Parameters:
shouldValidate
- true if this parameter should attempt to validate
-
findValue
Description copied from interface:Parameter
Attempts to find the value from the specifiedMacroExecutionContext
object.- Specified by:
findValue
in interfaceParameter<T>
- Parameters:
ctx
- The execution context for the macro.- Returns:
- The parameter value.
- Throws:
ParameterException
- if there was a problem while processing the parameter.
-
findObject
protected abstract T findObject(String paramValue, MacroExecutionContext ctx) throws ParameterException Responsible for converting a macro parameter string value to its proper object representation (say "1" to new Integer(1))- Throws:
ParameterException
-