Class AbstractParam<T>

    • Constructor Detail

      • AbstractParam

        protected AbstractParam​(@Nullable String input)
        Given an input value from a client, creates a parameter wrapping its parsed value.
        Parameters:
        input - an input value from a client request, might be null
      • AbstractParam

        protected AbstractParam​(@Nullable String input,
                                String parameterName)
        Given an input value from a client, creates a parameter wrapping its parsed value.
        Parameters:
        input - an input value from a client request, might be null
        parameterName - name of the parameter with the provided value
    • Method Detail

      • generateErrorMessage

        protected ErrorMessage generateErrorMessage​(@Nullable String input,
                                                    Exception e)
        Generates an ErrorMessage to return to the client.
        Parameters:
        input - the raw input value
        e - the exception thrown while parsing input
        Returns:
        the ErrorMessage with the message and status to return to the client
      • error

        @Deprecated
        protected @Nullable javax.ws.rs.core.Response error​(@Nullable String input,
                                                            Exception e)
        Deprecated.
        instead of returning a Response from this method, subclasses should override errorMessage(java.lang.Exception) and getErrorStatus() to allow a WebApplicationException to be thrown which is mapped to a response using the exception mappers.
        Deprecated - instead of throwing a WebApplicationException that contains a response with an entity, AbstractParam now throws a WebApplicationException that contains a message and status code, and can be mapped to a response using exception mappers. This method is kept for backwards compatibility with user-defined AbstractParam implementations that implement custom error behavior by overriding this method.

        Given a string representation which was unable to be parsed and the exception thrown, produce a Response to be sent to the client.

        Parameters:
        input - the raw input value
        e - the exception thrown while parsing input
        Returns:
        the Response to be sent to the client, or null to allow AbstractParam to throw a WebApplicationException that contains a message and status code.
      • mediaType

        @Deprecated
        protected javax.ws.rs.core.MediaType mediaType()
        Deprecated.
        the media type should be set by the exception mapper instead
        Deprecated - the media type should be set by the exception mapper instead. This method is no longer called by AbstractParam.
        Returns:
        not used
      • errorMessage

        protected String errorMessage​(Exception e)
        Given a string representation which was unable to be parsed and the exception thrown, produce an error message to be sent to the client.
        Parameters:
        e - the exception thrown while parsing input
        Returns:
        the error message to be sent the client
      • getErrorStatus

        protected javax.ws.rs.core.Response.Status getErrorStatus()
        Given a string representation which was unable to be parsed, produce a Response.Status for the Response to be sent to the client.
        Returns:
        the HTTP Response.Status of the error message
      • parse

        protected abstract T parse​(@Nullable String input)
                            throws Exception
        Given a string representation, parse it and return an instance of the parameter type.
        Parameters:
        input - the raw input
        Returns:
        input, parsed as an instance of T
        Throws:
        Exception - if there is an error parsing the input
      • get

        public T get()
        Returns the underlying value.
        Returns:
        the underlying value
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object