@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=bar&category=baz
.
Parameter names and values are URL encoded by default. Specify encoded=true
to change this behavior.
@GET("/search") void list(@Query(value="foo", encoded=true) String foo);Calling with
foo.list("foo+bar"))
yields /search?foo=foo+bar
.QueryMap
Copyright © 2015 Square, Inc.. All Rights Reserved.