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

    See Also:
    MessagePathParameter, MessageQueryParameter
    • 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, or null 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