Class HandlerRequest<R extends RequestBody>
- java.lang.Object
-
- org.apache.flink.runtime.rest.handler.HandlerRequest<R>
-
- Type Parameters:
R- type of the contained request body
public class HandlerRequest<R extends RequestBody> extends Object
Simple container for the request to a handler, that contains theRequestBodyand path/query parameters.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <R extends RequestBody,M extends MessageParameters>
HandlerRequest<R>create(R requestBody, M messageParameters)Short-cut forcreate(RequestBody, MessageParameters, Collection)without any uploaded files.static <R extends RequestBody,M extends MessageParameters>
HandlerRequest<R>create(R requestBody, M messageParameters, Collection<File> uploadedFiles)Creates a newHandlerRequest.<X,PP extends MessagePathParameter<X>>
XgetPathParameter(Class<PP> parameterClass)Returns the value of theMessagePathParameterfor the given class.<X,QP extends MessageQueryParameter<X>>
List<X>getQueryParameter(Class<QP> parameterClass)Returns the value of theMessageQueryParameterfor the given class.RgetRequestBody()Returns the request body.Collection<File>getUploadedFiles()static <R extends RequestBody,M extends MessageParameters>
HandlerRequest<R>resolveParametersAndCreate(R requestBody, M messageParameters, Map<String,String> receivedPathParameters, Map<String,List<String>> receivedQueryParameters, Collection<File> uploadedFiles)Creates a newHandlerRequestafter resolving the givenMessageParametersagainst the given query/path parameter maps.
-
-
-
Method Detail
-
getRequestBody
public R getRequestBody()
Returns the request body.- Returns:
- request body
-
getPathParameter
public <X,PP extends MessagePathParameter<X>> X getPathParameter(Class<PP> parameterClass)
Returns the value of theMessagePathParameterfor the given class.- Type Parameters:
X- the value type that the parameter containsPP- type of the path parameter- Parameters:
parameterClass- class of the parameter- Returns:
- path parameter value for the given class
- Throws:
IllegalStateException- if no value is defined for the given parameter class
-
getQueryParameter
public <X,QP extends MessageQueryParameter<X>> List<X> getQueryParameter(Class<QP> parameterClass)
Returns the value of theMessageQueryParameterfor the given class.- Type Parameters:
X- the value type that the parameter containsQP- type of the query parameter- Parameters:
parameterClass- class of the parameter- Returns:
- query parameter value for the given class, or an empty list if no parameter value exists for the given class
-
getUploadedFiles
@Nonnull public Collection<File> getUploadedFiles()
-
create
@VisibleForTesting public static <R extends RequestBody,M extends MessageParameters> HandlerRequest<R> create(R requestBody, M messageParameters)
Short-cut forcreate(RequestBody, MessageParameters, Collection)without any uploaded files.
-
create
@VisibleForTesting public static <R extends RequestBody,M extends MessageParameters> HandlerRequest<R> create(R requestBody, M messageParameters, Collection<File> uploadedFiles)
Creates a newHandlerRequest. The givenMessageParametersare expected to be resolved.
-
resolveParametersAndCreate
public static <R extends RequestBody,M extends MessageParameters> HandlerRequest<R> resolveParametersAndCreate(R requestBody, M messageParameters, Map<String,String> receivedPathParameters, Map<String,List<String>> receivedQueryParameters, Collection<File> uploadedFiles) throws HandlerRequestException
Creates a newHandlerRequestafter resolving the givenMessageParametersagainst the given query/path parameter maps.For tests it is recommended to resolve the parameters manually and use
create(R, M).- Throws:
HandlerRequestException
-
-