Class MessageParameter<X>
- java.lang.Object
-
- org.apache.flink.runtime.rest.messages.MessageParameter<X>
-
- Direct Known Subclasses:
MessagePathParameter
,MessageQueryParameter
public abstract class MessageParameter<X> extends Object
This class represents a single path/query parameter that can be used for a request. Every parameter has an associated key, and a one-time settable value.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)
andconvertToString(Object)
. The conversion fromX
to string is required on the client to assemble the URL, whereas the conversion from string toX
is required on the server to provide properly typed parameters to the handlers.- See Also:
MessagePathParameter
,MessageQueryParameter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
MessageParameter.MessageParameterRequisiteness
Enum for indicating whether a parameter is mandatory or optional.
-
Constructor Summary
Constructors Modifier Constructor Description protected
MessageParameter(String key, MessageParameter.MessageParameterRequisiteness requisiteness)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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, ornull
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.
-
-
-
Constructor Detail
-
MessageParameter
protected MessageParameter(String key, MessageParameter.MessageParameterRequisiteness requisiteness)
-
-
Method Detail
-
isResolved
public final boolean isResolved()
Returns whether this parameter has been resolved.- Returns:
- true, if this parameter was resolved, false otherwise
-
resolve
public final void resolve(X value)
Resolves this parameter for the given value.- Parameters:
value
- value to resolve this parameter with
-
resolveFromString
public final void resolveFromString(String value) throws ConversionException
Resolves this parameter for the given string value representation.- Parameters:
value
- string representation of value to resolve this parameter with- Throws:
ConversionException
-
convertFromString
protected abstract X convertFromString(String value) throws ConversionException
Converts the given string to a valid value of this parameter.- Parameters:
value
- string representation of parameter value- Returns:
- parameter value
- Throws:
ConversionException
-
convertToString
protected abstract String convertToString(X value)
Converts the given value to its string representation.- Parameters:
value
- parameter value- Returns:
- string representation of typed value
-
getKey
public final String getKey()
Returns the key of this parameter, e.g. "jobid".- Returns:
- key of this parameter
-
getValue
public final X getValue()
Returns the resolved value of this parameter, ornull
if it isn't resolved yet.- Returns:
- resolved value, or null if it wasn't resolved yet
-
isMandatory
public final boolean isMandatory()
Returns whether this parameter must be resolved for the request.- Returns:
- true if the parameter is mandatory, false otherwise
-
getDescription
public abstract String getDescription()
Returns a description for REST API HTML documentation.- Returns:
- escaped HTML string
-
-