title: “Java Method Parameters” slug: JavaMethodParameters

Java methods can contain any of the following parameters in any order:

In Spring Boot environments, any available Spring Beans can also be passed in as parameters.

:::tip Example

@RestGet("/example1/{a1}/{a2}/{a3}/*")
public String doGetExample1(
    RestRequest req,
    RestResponse res,
    @Method String method,
    @Path("a1") String a1,
    @Path("a2") int a2,
    @Path("a3") UUID a3,
    @Query("p1") int p1,
    @Query("p2") String p2,
    @Query("p3") UUID p3,
    @HasQuery("p3") boolean hasP3,
    @Path("/*") String remainder,
    @Header("Accept-Language") String lang,
    @Header("Accept") String accept,
    @Header("DNT") int doNotTrack,
    RequestAttributes attributes,
    ResourceBundle nls
) {
    // Do something with all of those
}

:::

Additional parameter types can be defined via the annotation Rest.restOpArgs() or by supplying a named bean via @Bean.

:::tip Example

@Rest(
    restOpArgs={ MyOpArg.class }  // Option #1 - Via annotation
)
public class MyResource extends BasicRestObject {

}

:::