I created the Java Invoice Builder , which at compile time creates collectors that invoke methods. It also adds support for default values โโfor method parameters in Java.
It can be used for classes or interfaces. By adding @GenerateMethodInvocationBuilder and @Default annotations to the type.
@GenerateMethodInvocationBuilder public interface BitBucketServerService { @GET("/rest/api/1.0/projects/{projectkey}/repos/{repositoryslug}/pull-requests?direction={direction}&at={at}&state={state}&order={order}&withattributes={withattributes}&withproperties={withproperties}") Call<BitbucketServerResponse<BitBucketServerPullRequest>> pullRequests(// @Default("PROJ") @Query("projectkey") String projectKey,// @Default("REPO") @Query("repositoryslug") String repositoryslug,// @Default("INCOMING") @Query("direction") String direction,// @Default("23") @Query("at") String at,// @Default("OPEN") @Query("state") String state,// @Default("NEWEST") @Query("order") String order,// @Default("true") @Query("withattributes") String withattributes,// @Default("true") @Query("withproperties") String withproperties); }
Then, when the compiler is compiled, a builder will be created, and you can call it with the default parameters:
BitBucketServerServicePullRequestsBuilder.pullRequests() .invoke(bitBucketServerService);
Or set any parameters you like:
BitBucketServerServicePullRequestsBuilder.pullRequests() .withAt("24") .invoke(bitBucketServerService);
More on GitHub: https://github.com/tomasbjerre/java-method-invocation-builder
source share