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:
InstantParam,InstantSecondParam,IntParam,LocalDateParam,LocalDateTimeParam,LocalTimeParam,LongParam,NonEmptyStringParam,OffsetDateTimeParam,UUIDParam,YearMonthParam,YearParam,ZonedDateTimeParam,ZoneIdParam
An abstract base class from which to build Jersey parameter classes.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractParam(@Nullable String input) Given an input value from a client, creates a parameter wrapping its parsed value.protectedAbstractParam(@Nullable String input, String parameterName) Given an input value from a client, creates a parameter wrapping its parsed value. -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected @Nullable jakarta.ws.rs.core.ResponseDeprecated.protected StringGiven a string representation which was unable to be parsed and the exception thrown, produce an error message to be sent to the client.protected ErrorMessagegenerateErrorMessage(@Nullable String input, Exception e) Generates anErrorMessageto return to the client.get()Returns the underlying value.protected jakarta.ws.rs.core.Response.StatusGiven a string representation which was unable to be parsed, produce aResponse.Statusfor theResponseto be sent to the client.inthashCode()protected jakarta.ws.rs.core.MediaTypeDeprecated.the media type should be set by the exception mapper insteadprotected abstract TGiven a string representation, parse it and return an instance of the parameter type.toString()
-
Constructor Details
-
AbstractParam
Given an input value from a client, creates a parameter wrapping its parsed value.- Parameters:
input- an input value from a client request, might benull
-
AbstractParam
Given an input value from a client, creates a parameter wrapping its parsed value.- Parameters:
input- an input value from a client request, might benullparameterName- name of the parameter with the provided value
-
-
Method Details
-
generateErrorMessage
Generates anErrorMessageto return to the client.- Parameters:
input- the raw input valuee- the exception thrown while parsinginput- Returns:
- the
ErrorMessagewith the message and status to return to the client
-
error
@Deprecated protected @Nullable jakarta.ws.rs.core.Response error(@Nullable String input, Exception e) Deprecated.instead of returning aResponsefrom this method, subclasses should overrideerrorMessage(java.lang.Exception)andgetErrorStatus()to allow aWebApplicationExceptionto be thrown which is mapped to a response using the exception mappers.Deprecated - instead of throwing aWebApplicationExceptionthat contains a response with an entity, AbstractParam now throws aWebApplicationExceptionthat 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
Responseto be sent to the client.- Parameters:
input- the raw input valuee- the exception thrown while parsinginput- Returns:
- the
Responseto be sent to the client, ornullto allow AbstractParam to throw aWebApplicationExceptionthat contains a message and status code.
-
mediaType
Deprecated.the media type should be set by the exception mapper insteadDeprecated - the media type should be set by the exception mapper instead. This method is no longer called by AbstractParam.- Returns:
- not used
-
errorMessage
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 parsinginput- Returns:
- the error message to be sent the client
-
getErrorStatus
protected jakarta.ws.rs.core.Response.Status getErrorStatus()Given a string representation which was unable to be parsed, produce aResponse.Statusfor theResponseto be sent to the client.- Returns:
- the HTTP
Response.Statusof the error message
-
parse
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
Returns the underlying value.- Returns:
- the underlying value
-
equals
-
hashCode
public int hashCode() -
toString
-
Responsefrom this method, subclasses should overrideerrorMessage(java.lang.Exception)andgetErrorStatus()to allow aWebApplicationExceptionto be thrown which is mapped to a response using the exception mappers.