public abstract class

BaseParameter

extends Object
implements Parameter<T>
java.lang.Object
   ↳ com.atlassian.confluence.macro.params.BaseParameter<T>
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

A base implementation of Parameter, providing support for multiple default parameter names, and a default value if no parameter is specified.

Summary

Fields
protected boolean shouldValidate
Protected Constructors
BaseParameter(String name, String defaultValue)
BaseParameter(String[] names, String defaultValue)
BaseParameter(List<String> names, String defaultValue)
Public Methods
@Deprecated final void addParameterAlias(String name)
This method is deprecated. since 3.1: this class is not thread safe and should not be mutated
final T findValue(MacroExecutionContext ctx)
Attempts to find the value from the specified MacroExecutionContext object.
final String getDefaultValue()
Returns the default value for this parameter if no match is found in the context.
final String getParameterValue(Map<StringString> params)
Returns the literal value of the parameter, or the default value if none is present.
@Deprecated final void setDefaultValue(String defaultValue)
This method is deprecated. since 3.1: this class is not thread safe and should not be mutated
@Deprecated final void setParameterNames(String[] names)
This method is deprecated. since 3.1: this class is not thread safe and should not be mutated
final void setValidate(boolean shouldValidate)
Sets whether this parameter should attempt to validate its values.
Protected Methods
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 String getParameter(Map<StringString> 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.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.confluence.macro.params.Parameter

Fields

protected boolean shouldValidate

Protected Constructors

protected BaseParameter (String name, String defaultValue)

protected BaseParameter (String[] names, String defaultValue)

protected BaseParameter (List<String> names, String defaultValue)

Public Methods

@Deprecated public final void addParameterAlias (String name)

This method is deprecated.
since 3.1: this class is not thread safe and should not be mutated

Adds the specified String as an alias to the default name of this parameter.

Parameters
name another name for the parameter recognized by this object

public final T findValue (MacroExecutionContext ctx)

Attempts to find the value from the specified MacroExecutionContext object.

Parameters
ctx The execution context for the macro.
Returns
  • The parameter value.

public final String getDefaultValue ()

Returns the default value for this parameter if no match is found in the context.

Returns
  • the default value for this parameter

public final String getParameterValue (Map<StringString> params)

Returns the literal value of the parameter, or the default value if none is present.

Parameters
params the Map of parameters to search
Returns
  • the literal value of the parameter

@Deprecated public final void setDefaultValue (String defaultValue)

This method is deprecated.
since 3.1: this class is not thread safe and should not be mutated

Sets 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

@Deprecated public final void setParameterNames (String[] names)

This method is deprecated.
since 3.1: this class is not thread safe and should not be mutated

Sets the specified String array as the names by which to recognize this parameter.

Parameters
names the names of the parameter to recognize

public final void setValidate (boolean shouldValidate)

Sets whether this parameter should attempt to validate its values.

Parameters
shouldValidate true if this parameter should attempt to validate

Protected Methods

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))

protected final String getParameter (Map<StringString> 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.

Parameters
params the Map of parameters to search
names the parameter names to look for
defaultValue the default value to return if no match is found
Returns
  • the parameter value, or the default if none is found