@Documented @Target(value=PARAMETER) @Retention(value=RUNTIME) public @interface Query
Values are converted to strings using String.valueOf(Object)
and then URL encoded.
null
values are ignored. Passing a List
or array will result in a
query parameter for each non-null
item.
Simple Example:
@GET("/list") void list(@Query("page") int page);Calling with
foo.list(1)
yields /list?page=1
.
Example with null
:
@GET("/list") void list(@Query("category") String category);Calling with
foo.list(null)
yields /list
.
Array Example:
@GET("/list") void list(@Query("category") String... categories);Calling with
foo.list("bar", "baz")
yields
/list?category=foo&category=bar
.
Parameter names are not URL encoded. Specify encodeName=true
to change
this behavior.
@GET("/search") void list(@Query(value="foo+bar", encodeName=true) String foobar);Calling with
foo.list("baz")
yields /search?foo%2Bbar=foo
.
Parameter values are URL encoded by default. Specify encodeValue=false
to
change this behavior.
@GET("/search") void list(@Query(value="foo", encodeValue=false) String foo);Calling with
foo.list("foo+foo"))
yields /search?foo=foo+bar
.QueryMap
Modifier and Type | Required Element and Description |
---|---|
String |
value
The query parameter name.
|
Modifier and Type | Optional Element and Description |
---|---|
boolean |
encodeName
Specifies whether
value() is URL encoded. |
boolean |
encodeValue
Specifies whether the argument value to the annotated method parameter is URL encoded.
|
Copyright © 2015 Square, Inc.. All Rights Reserved.