Class Profile.Parameter<P extends Profile.Parameter<P,T>,T>
- java.lang.Object
-
- org.forgerock.opendj.setup.model.Profile.Parameter<P,T>
-
- Type Parameters:
P
- The parameter implementationT
- The parameter value concrete class
- Direct Known Subclasses:
Profile.DnParameter
,Profile.DomainParameter
,Profile.EnumParameter
,Profile.HostPortParameter
,Profile.NumberParameter
,Profile.PasswordParameter
,Profile.PathParameter
,Profile.StringParameter
- Enclosing class:
- Profile
public abstract class Profile.Parameter<P extends Profile.Parameter<P,T>,T> extends Object
Represents parameters that are defined in parameters.groovy and can be used in the profile.groovy script.A parameter is defined by:
- a mandatory variable name (e.g fooBar)
- an optional property name (e.g FOO_BAR), this property will be used for substituting commons
configuration expression in resource files (see
Profile.ResourcesManager.applyTemplate(String, String)
) - a default value which will be used if no values are provided for the parameter at runtime
- a value
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract <R,P2,E extends Exception>
Raccept(Profile.ParameterVisitor<R,P2,E> visitor, P2 p)
Applies aProfile.ParameterVisitor
to thisProfile.Parameter
.P
advanced()
Specifies that thisprofile parameter
is advanced.P
defaultValue(String defaultValue)
Sets this profile parameter default value with the provided string.P
defaultValue(T defaultValue)
Sets this profile parameter default value.boolean
defaultValueCanBeDerivedAtSetup()
Returnstrue
if the default value of this parameter can be derived from the setup global options.P
defaultValueFromSetupTool(String setupConfMethod)
Indicates that this profile parameter value must be computed using theProfile.SetupConfiguration
if no value is available at runtime.P
description(String descriptionMsg)
Sets this profile parameter description.P
descriptionIfNoValueSet(String descriptionIfNoValueSetMsg)
Sets the message to be displayed instead of theparameter description
if no value is provided for this parameter.boolean
equals(Object obj)
P
expressionAllowed()
Specifies that common configuration expressions can be specified for thisprofile parameter
.LocalizableMessage
getAddAnotherValueMsg()
Returns prompt message to know whether another value should be added for this parameter.ValueOrExpression<T>
getDefaultValue()
Returns this profile parameter default value.LocalizableMessage
getDescriptionIfNoValueSetMsg()
Returns this profile parameter description to be used when no value is provided.LocalizableMessage
getDescriptionMsg()
Returns this profile parameter description.LocalizableMessage
getHelpMsg()
Returns this profile parameter help message.LocalizableMessage
getOptionalPromptMsg()
Returns prompt message to know whether a value should be provided for this parameter.LocalizableMessage
getPromptForValueMsg()
Returns this profile parameter prompt message.String
getSyntax()
Returns this parameter type.String
getSyntaxWithoutExpression()
Returns this parameter type.T
getValue()
Returns this profile parameter value.Object
getValueOrExpression()
Returns this profile parameter value or expression.String
getVariableName()
Returns this profile parameter variable name.int
hashCode()
P
help(String helpMsg)
Sets this profile parameter help.boolean
isAdvanced()
Returns whether thisprofile parameter
is advanced.boolean
isMultivalued()
Returns whether thisprofile parameter
is multivalued.boolean
isOptional()
Returns whether thisprofile parameter
is optional.P
multivalued()
Specifies that thisprofile parameter
can accept multiple values.P
multivalued(String... addAnotherValueMsg)
Specifies that thisprofile parameter
can accept multiple values.P
optional()
Specifies that thisprofile parameter
is optional.P
optional(String... optionalPromptMsg)
Specifies that thisprofile parameter
is optional.abstract T
parseStringValue(String strValue)
Parses provided string value into this parameter type and returns the typed value.P
prompt(String... promptForValueMsg)
Sets this profile parameter prompt message.P
property(String property)
Sets this profile parameter property.String
toString()
-
-
-
Method Detail
-
defaultValueFromSetupTool
public final P defaultValueFromSetupTool(String setupConfMethod) throws SetupException
Indicates that this profile parameter value must be computed using theProfile.SetupConfiguration
if no value is available at runtime.This is possible when the associated
profile
isrun
by thesetup tool
. It is not possible when the associatedprofile
isrun
by thesetup-profile tool
.If no value is available at runtime and it is not possible to retrieve the value from the
Profile.SetupConfiguration
, the parameterdefault value
will be used.- Parameters:
setupConfMethod
- String representing the method name to be called on theProfile.SetupConfiguration
to get this parameter value- Returns:
- This
profile parameter
- Throws:
SetupException
- If noProfile.SetupConfiguration
method is available with the provided name
-
defaultValue
public final P defaultValue(T defaultValue)
Sets this profile parameter default value.If no value is available for the parameter at runtime, default value will be used.
- Parameters:
defaultValue
- The default value to be associated to this parameter- Returns:
- This
profile parameter
-
defaultValue
public final P defaultValue(String defaultValue) throws SetupException
Sets this profile parameter default value with the provided string.If no value is available for the parameter at runtime, default value will be used.
- Parameters:
defaultValue
- A string representing the default value to be associated to this parameter- Returns:
- This
profile parameter
- Throws:
SetupException
- If the provided string cannot be converted in the parameter object type
-
description
public final P description(String descriptionMsg)
Sets this profile parameter description.Description will be used by setup tool interactive mode in summaries, hence description content should be concise (e.g Name of the backend used to ...
- Parameters:
descriptionMsg
- A string representing the parameter description message- Returns:
- This
profile parameter
-
help
public final P help(String helpMsg)
Sets this profile parameter help.Help is printed when user wants to know all parameters associated to a profile (setup --help-profile "profileId"), if not set
description
will be used.- Parameters:
helpMsg
- A string representing the parameter help message- Returns:
- This
profile parameter
-
advanced
public final P advanced()
Specifies that thisprofile parameter
is advanced.Setup interactive mode
does not prompt for advanced profile parameter value. As a consequence, advanced parameter must have a default value defined.- Returns:
- This
profile parameter
-
multivalued
public final P multivalued(String... addAnotherValueMsg)
Specifies that thisprofile parameter
can accept multiple values.- Parameters:
addAnotherValueMsg
- Strings representing the paragraphs of the message to be printed to ask if another value must be added for this parameter- Returns:
- This
profile parameter
-
multivalued
public final P multivalued()
Specifies that thisprofile parameter
can accept multiple values.- Returns:
- This
profile parameter
-
expressionAllowed
public P expressionAllowed()
Specifies that common configuration expressions can be specified for thisprofile parameter
.- Returns:
- This
profile parameter
-
optional
public final P optional(String... optionalPromptMsg)
Specifies that thisprofile parameter
is optional.Profile framework will not fail if no value has been provided for an optional parameter.
- Parameters:
optionalPromptMsg
- Strings representing the paragraphs of message to ask the user to know whether a value should be provided for this parameter- Returns:
- This
profile parameter
-
optional
public final P optional()
Specifies that thisprofile parameter
is optional.Profile framework will not fail if no value has been provided for an optional parameter.
- Returns:
- This
profile parameter
-
descriptionIfNoValueSet
public P descriptionIfNoValueSet(String descriptionIfNoValueSetMsg)
Sets the message to be displayed instead of theparameter description
if no value is provided for this parameter.Message will be used by setup tool interactive mode in summaries, hence it should be concise.
- Parameters:
descriptionIfNoValueSetMsg
- Strings representing the parameter description message paragraphs- Returns:
- This
profile parameter
-
prompt
public final P prompt(String... promptForValueMsg)
Sets this profile parameter prompt message.- Parameters:
promptForValueMsg
- Strings representing the paragraphs of the message to be printed when resolving thisprofile parameter
value- Returns:
- This
profile parameter
-
property
public final P property(String property)
Sets this profile parameter property.- Parameters:
property
- The property to be associated to this parameter- Returns:
- This
profile parameter
-
parseStringValue
public abstract T parseStringValue(String strValue) throws com.forgerock.opendj.cli.ArgumentException
Parses provided string value into this parameter type and returns the typed value.- Parameters:
strValue
- A string representing the parameter value to be parsed- Returns:
- The typed value associated to provided string
- Throws:
com.forgerock.opendj.cli.ArgumentException
- If an error occurred while parsing provided string value
-
isAdvanced
public final boolean isAdvanced()
Returns whether thisprofile parameter
is advanced.the setup interactive mode does not prompt for an advanced profile parameter value.
- Returns:
true
if thisprofile parameter
is advanced,false
otherwise- See Also:
advanced()
-
isMultivalued
public final boolean isMultivalued()
Returns whether thisprofile parameter
is multivalued.- Returns:
true
if thisprofile parameter
is multivalued,false
otherwise- See Also:
multivalued()
-
isOptional
public final boolean isOptional()
Returns whether thisprofile parameter
is optional.- Returns:
true
if thisprofile parameter
is optional,false
otherwise- See Also:
optional(String...)
,optional()
-
defaultValueCanBeDerivedAtSetup
public boolean defaultValueCanBeDerivedAtSetup()
Returnstrue
if the default value of this parameter can be derived from the setup global options.- Returns:
true
if the default value of this parameter can be derived from the setup global options,false
otherwise- See Also:
defaultValueFromSetupTool(String)
-
getDefaultValue
public final ValueOrExpression<T> getDefaultValue()
Returns this profile parameter default value.- Returns:
- This
profile parameter
default value
-
getDescriptionMsg
public final LocalizableMessage getDescriptionMsg()
Returns this profile parameter description.If no message has been set for the description to be returned, a generic message is used.
- Returns:
- A
LocalizableMessage
representing thisprofile parameter
description
-
getDescriptionIfNoValueSetMsg
public final LocalizableMessage getDescriptionIfNoValueSetMsg()
Returns this profile parameter description to be used when no value is provided.If no message has been set for this particular use case, the profile parameter
description
is returned.- Returns:
- A
LocalizableMessage
representing thisprofile parameter
description when no value is provided
-
getHelpMsg
public final LocalizableMessage getHelpMsg()
Returns this profile parameter help message.- Returns:
- A
LocalizableMessage
representing thisprofile parameter
help message
-
getPromptForValueMsg
public final LocalizableMessage getPromptForValueMsg()
Returns this profile parameter prompt message.- Returns:
- A
LocalizableMessage
representing thisprofile parameter
prompt message
-
getOptionalPromptMsg
public final LocalizableMessage getOptionalPromptMsg()
Returns prompt message to know whether a value should be provided for this parameter.- Returns:
- A
LocalizableMessage
printed when asking if a value should be provided for this parameter
-
getAddAnotherValueMsg
public LocalizableMessage getAddAnotherValueMsg()
Returns prompt message to know whether another value should be added for this parameter.- Returns:
- A
LocalizableMessage
printed when asking if a value should be added for this parameter
-
getVariableName
public final String getVariableName()
Returns this profile parameter variable name.- Returns:
- A string representing this
profile parameter
variable name
-
getSyntax
public final String getSyntax()
Returns this parameter type.- Returns:
- A string representing this parameter type
-
getSyntaxWithoutExpression
public final String getSyntaxWithoutExpression()
Returns this parameter type.The returned string does not mention that this parameter can contain configuration expression.
- Returns:
- A string representing this parameter type
-
getValue
public final T getValue() throws ExpressionException
Returns this profile parameter value.To be set,
resolveValues(ExecutionContext)
method must have been called.- Returns:
- This
profile parameter
value - Throws:
ExpressionException
- If the parameter contains an expression
-
getValueOrExpression
public final Object getValueOrExpression()
Returns this profile parameter value or expression.To be set,
resolveValues(ExecutionContext)
method must have been called.- Returns:
- This
profile parameter
value
-
accept
public abstract <R,P2,E extends Exception> R accept(Profile.ParameterVisitor<R,P2,E> visitor, P2 p) throws E extends Exception
Applies aProfile.ParameterVisitor
to thisProfile.Parameter
.- Type Parameters:
R
- The return type of the visitor's methodsP2
- The type of the additional parameter to this visitor's methods. UseVoid
for visitors that do not need an additional parameterE
- The type of the exception thrown by the visitor method if it fails, orNeverThrowsException
if the visitor cannot fail- Parameters:
visitor
- The parameter visitorp
- Optional additional visitor parameter- Returns:
- A result as specified by the visitor
- Throws:
E
- If the visitor failedE extends Exception
-
-