public abstract class MessageParameter<X> extends Object
Parameters are either mandatory or optional, indicating whether the parameter must be resolved for the request.
All parameters support symmetric conversion from their actual type and string via convertFromString(String)
and convertToString(Object)
. The conversion from X
to string is required on the client to assemble the URL, whereas the conversion from string to
X
is required on the server to provide properly typed parameters to the handlers.
MessagePathParameter
,
MessageQueryParameter
Modifier and Type | Class and Description |
---|---|
protected static class |
MessageParameter.MessageParameterRequisiteness
Enum for indicating whether a parameter is mandatory or optional.
|
Modifier | Constructor and Description |
---|---|
protected |
MessageParameter(String key,
MessageParameter.MessageParameterRequisiteness requisiteness) |
Modifier and Type | Method and Description |
---|---|
protected abstract X |
convertFromString(String value)
Converts the given string to a valid value of this parameter.
|
protected abstract String |
convertToString(X value)
Converts the given value to its string representation.
|
abstract String |
getDescription()
Returns a description for REST API HTML documentation.
|
String |
getKey()
Returns the key of this parameter, e.g.
|
X |
getValue()
Returns the resolved value of this parameter, or
null if it isn't resolved yet. |
boolean |
isMandatory()
Returns whether this parameter must be resolved for the request.
|
boolean |
isResolved()
Returns whether this parameter has been resolved.
|
void |
resolve(X value)
Resolves this parameter for the given value.
|
void |
resolveFromString(String value)
Resolves this parameter for the given string value representation.
|
protected MessageParameter(String key, MessageParameter.MessageParameterRequisiteness requisiteness)
public final boolean isResolved()
public final void resolve(X value)
value
- value to resolve this parameter withpublic final void resolveFromString(String value) throws ConversionException
value
- string representation of value to resolve this parameter withConversionException
protected abstract X convertFromString(String value) throws ConversionException
value
- string representation of parameter valueConversionException
protected abstract String convertToString(X value)
value
- parameter valuepublic final String getKey()
public final X getValue()
null
if it isn't resolved yet.public final boolean isMandatory()
public abstract String getDescription()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.