All Downloads are FREE. Search and download functionalities are using the official Maven repository.

JavaSpring.methodBody.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
{{^reactive}}
{{#examples}}
    {{#-first}}
        {{#jdk8}}
            {{#async}}
return CompletableFuture.supplyAsync(()-> {
            {{/async}}getRequest().ifPresent(request -> {
{{#async}}    {{/async}}            {{/jdk8}}for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
    {{/-first}}
{{#async}}        {{/async}}{{^async}}{{#jdk8}}    {{/jdk8}}{{/async}}            if (mediaType.isCompatibleWith(MediaType.valueOf("{{{contentType}}}"))) {
{{#async}}        {{/async}}{{^async}}{{#jdk8}}    {{/jdk8}}{{/async}}                String exampleString = {{>exampleString}};
{{#async}}        {{/async}}{{^async}}{{#jdk8}}    {{/jdk8}}{{/async}}                ApiUtil.setExampleResponse(request, "{{{contentType}}}", exampleString);
{{#async}}        {{/async}}{{^async}}{{#jdk8}}    {{/jdk8}}{{/async}}                break;
{{#async}}        {{/async}}{{^async}}{{#jdk8}}    {{/jdk8}}{{/async}}            }
    {{#-last}}
{{#async}}        {{/async}}{{^async}}{{#jdk8}}    {{/jdk8}}{{/async}}        }
        {{#jdk8}}
{{#async}}    {{/async}}        });
        {{/jdk8}}
{{#async}}    {{/async}}        return new ResponseEntity<>({{#returnSuccessCode}}HttpStatus.valueOf({{{statusCode}}}){{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}});
        {{#jdk8}}
            {{#async}}
        }, Runnable::run);
            {{/async}}
        {{/jdk8}}
    {{/-last}}
{{/examples}}
{{^examples}}
return {{#jdk8}}{{#async}}CompletableFuture.completedFuture({{/async}}{{/jdk8}}new ResponseEntity<>({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}}){{#jdk8}}{{#async}}){{/async}}{{/jdk8}};
{{/examples}}
{{/reactive}}
{{#reactive}}
Mono result = Mono.empty();
    {{#examples}}
        {{#-first}}
        exchange.getResponse().setStatusCode({{#returnSuccessCode}}HttpStatus.valueOf({{{statusCode}}}){{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}});
        for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
        {{/-first}}
            if (mediaType.isCompatibleWith(MediaType.valueOf("{{{contentType}}}"))) {
                String exampleString = {{>exampleString}};
                result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
                break;
            }
        {{#-last}}
        }
        {{/-last}}
    {{/examples}}
{{^examples}}
        exchange.getResponse().setStatusCode({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}});
{{/examples}}
        return result.then(Mono.empty());
{{/reactive}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy