Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.yammer.dropwizard.jersey.params;
  
An abstract base class from which to build Jersey parameter classes.

Parameters:
<T> the type of value wrapped by the parameter
 
 public abstract class AbstractParam<T> {
     private final T value;

    
Given an input value from a client, creates a parameter wrapping its parsed value.

Parameters:
input an input value from a client request
 
     @SuppressWarnings({"AbstractMethodCallInConstructor""OverriddenMethodCallDuringObjectConstruction"})
     protected AbstractParam(String input) {
         try {
             this. = parse(input);
         } catch (Exception e) {
             throw new WebApplicationException(error(inpute));
         }
     }

    
Given a string representation which was unable to be parsed and the exception thrown, produce a javax.ws.rs.core.Response to be sent to the client. By default, generates a 400 Bad Request with a plain text entity generated by errorMessage(java.lang.String,java.lang.Exception).

Parameters:
input the raw input value
e the exception thrown while parsing input
Returns:
the javax.ws.rs.core.Response to be sent to the client
 
     protected Response error(String inputException e) {
         return Response.status(getErrorStatus())
                        .entity(errorMessage(inpute))
                        .type(mediaType())
                        .build();
     }

    
Returns the media type of the error message entity.

Returns:
the media type of the error message entity
 
     protected MediaType mediaType() {
         return .;
     }

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

Parameters:
input the raw input value
e the exception thrown while parsing input
Returns:
the error message to be sent the client
 
     protected String errorMessage(String inputException e) {
         return String.format("Invalid parameter: %s (%s)"inpute.getMessage());
     }

    
Given a string representation which was unable to be parsed, produce a javax.ws.rs.core.Response.Status for the javax.ws.rs.core.Response to be sent to the client.

Returns:
the HTTP javax.ws.rs.core.Response.Status of the error message
 
     @SuppressWarnings("MethodMayBeStatic")
     protected Status getErrorStatus() {
         return .;
     }

   
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:
java.lang.Exception if there is an error parsing the input
 
     protected abstract T parse(String inputthrows Exception;

    
Returns the underlying value.

Returns:
the underlying value
 
     public T get() {
         return ;
     }
 
     @Override
     public boolean equals(Object obj) {
        if (this == obj) { return true; }
        if ((obj == null) || (getClass() != obj.getClass())) { return false; }
        final AbstractParam<?> that = (AbstractParam<?>) obj;
        return .equals(that.value);
    }
    @Override
    public int hashCode() {
        return .hashCode();
    }
    @Override
    public String toString() {
        return .toString();
    }
New to GrepCode? Check out our FAQ X