@Query
The @Query annotation can be applied to arguments of @RemoteOp-annotated methods to denote that they are query parameters on the request.
Example
@Remote(path="/myproxy")
public interface MyProxy {
// Explicit names specified for query parameters.
@RemoteGet
String parameters(
@Query("foo") String foo,
@Query("bar") MyPojo pojo);
// Multiple values pulled from a PartList object.
// Same as @Query("*").
@RemoteGet
String partList(@Query PartList partList);
// Multiple values pulled from a Map.
// Same as @Query("*").
@RemoteGet
String map(@Query Map map);
// Multiple values pulled from a bean.
// Same as @Query("*").
@RemoteGet
String bean(@Query MyBean myBean);
// An entire query string as a String.
// Same as @Query("*").
@RemoteGet
String string(@Query String string);
// An entire query string as a Reader.
// Same as @Query("*").
@RemoteGet
String reader(@Query Reader reader);
}
Query arguments can be any of the following types:
-
Single-part arguments (i.e. those with
name != "*"
):- Any serializable POJO - Converted to a string using the HttpPartSerializer registered with the RestClient (OpenApiSerializer by default) or associated via the @Query(serializer) annotation.
-
Multi-part arguments (i.e. those with
name == "*"
or empty):- Reader - Raw contents of
Reader
will be serialized directly as query string. - PartList - Serialized as individual query parameters.
Map<String,Object>
- Converted to key-value pairs. Values serialized using the registered HttpPartSerializer (OpenApiSerializer by default).- Bean - Converted to key-value pairs. Values serialized using the registered HttpPartSerializer (OpenApiSerializer by default).
CharSequence
- Serialized directly as query string.
- Reader - Raw contents of
See the link below for information about supported data types in OpenAPI serialization.
See Also