Package io.dropwizard.jersey.params
Class AbstractParam<T>
- java.lang.Object
-
- io.dropwizard.jersey.params.AbstractParam<T>
-
- Type Parameters:
T
- the type of value wrapped by the parameter
- Direct Known Subclasses:
BooleanParam
,DateTimeParam
,DurationParam
,InstantParam
,InstantParam
,InstantSecondParam
,IntParam
,LocalDateParam
,LocalDateParam
,LocalDateTimeParam
,LocalTimeParam
,LongParam
,NonEmptyStringParam
,OffsetDateTimeParam
,SizeParam
,UUIDParam
,YearMonthParam
,YearParam
,ZonedDateTimeParam
,ZoneIdParam
public abstract class AbstractParam<T> extends Object
An abstract base class from which to build Jersey parameter classes.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractParam(String input)
protected
AbstractParam(String input, String parameterName)
Given an input value from a client, creates a parameter wrapping its parsed value.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
protected javax.ws.rs.core.Response
error(String input, Exception e)
Given a string representation which was unable to be parsed and the exception thrown, produce aResponse
to be sent to the client.protected String
errorMessage(Exception e)
Given a string representation which was unable to be parsed and the exception thrown, produce an entity to be sent to the client.T
get()
Returns the underlying value.protected javax.ws.rs.core.Response.Status
getErrorStatus()
Given a string representation which was unable to be parsed, produce aResponse.Status
for theResponse
to be sent to the client.int
hashCode()
protected javax.ws.rs.core.MediaType
mediaType()
Returns the media type of the error message entity.protected abstract T
parse(String input)
Given a string representation, parse it and return an instance of the parameter type.String
toString()
-
-
-
Constructor Detail
-
AbstractParam
protected AbstractParam(@Nullable String input)
-
-
Method Detail
-
error
protected javax.ws.rs.core.Response error(@Nullable String input, Exception e)
Given a string representation which was unable to be parsed and the exception thrown, produce aResponse
to be sent to the client. By default, generates a400 Bad Request
with a plain text entity generated byerrorMessage(Exception)
.- Parameters:
input
- the raw input valuee
- the exception thrown while parsinginput
- Returns:
- the
Response
to be sent to the client
-
mediaType
protected javax.ws.rs.core.MediaType mediaType()
Returns the media type of the error message entity.- Returns:
- the media type of the error message entity
-
errorMessage
protected String errorMessage(Exception e)
Given a string representation which was unable to be parsed and the exception thrown, produce an entity to be sent to the client.- Parameters:
e
- the exception thrown while parsinginput
- 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 aResponse.Status
for theResponse
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 ofT
- Throws:
Exception
- if there is an error parsing the input
-
get
public T get()
Returns the underlying value.- Returns:
- the underlying value
-
-