Skip to content

Instantly share code, notes, and snippets.

@sandipchitale
Last active August 27, 2023 21:02
Show Gist options
  • Save sandipchitale/2b2cef9c5664a0e51d2d0cad971620c7 to your computer and use it in GitHub Desktop.
Save sandipchitale/2b2cef9c5664a0e51d2d0cad971620c7 to your computer and use it in GitHub Desktop.
Live Templates #intellij
record $MODEL$(long id, String name) {}
@Bean
@Qualifier("$DCMODEL$-rest-client")
RestClient $DCMODEL$RestClient(RestClient.Builder builder) {
return builder.baseUrl("https://$DCMODEL$.api.com/$MODEL$s").build();
}
interface $MODEL$Service {
@GetExchange
List<$MODEL$> get$MODEL$s();
@GetExchange("/{id}")
$MODEL$ get$MODEL$(@PathVariable("id") long id);
}
@Bean
$MODEL$Service $DCMODEL$Service(@Qualifier("$DCMODEL$-rest-client") RestClient restClient) {
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builderFor(RestClientAdapter.create(restClient)).build();
return proxyFactory.createClient($MODEL$Service.class);
}
record $MODEL$(long id, String name) {}
@Bean
@Qualifier("$DCMODEL$-rest-template")
RestTemplate $DCMODEL$RestTemplate(RestTemplateBuilder builder) {
return builder.rootUri("https://$DCMODEL$.api.com/$MODEL$s").build();
}
interface $MODEL$Service {
@GetExchange
List<$MODEL$> get$MODEL$s();
@GetExchange("/{id}")
$MODEL$ get$MODEL$(@PathVariable("id") long id);
}
@Bean
$MODEL$Service $DCMODEL$Service(@Qualifier("$DCMODEL$-rest-template") RestTemplate restTemplate) {
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builderFor(RestTemplateAdapter.create(restTemplate)).build();
return proxyFactory.createClient($MODEL$Service.class);
}
record $MODEL$(long id, long userid, String title, boolean completed) {}
@Bean
@Qualifier("$DCMODEL$-web-client")
WebClient $DCMODEL$WebClient(WebClient.Builder builder) {
return builder.baseUrl("https://$DCMODEL$.api.com/$MODEL$s").build();
}
interface $MODEL$Service {
@GetExchange
List<$MODEL$> get$MODEL$s();
@GetExchange("/{id}")
$MODEL$ get$MODEL$(@PathVariable("id") long id);
}
@Bean
$MODEL$Service $DCMODEL$Client(@Qualifier("$DCMODEL$-web-client") WebClient webClient) {
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(WebClientAdapter.forClient(webClient)).build();
return proxyFactory.createClient($MODEL$Service.class);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment