From 5120a6bae7622d217cf5d9c7498946d48de3379c Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Mon, 10 Jun 2024 16:58:41 +1200 Subject: [PATCH] spotless Signed-off-by: Thomas Farr --- .../org/opensearch/client/codegen/Main.java | 8 ++--- .../codegen/model/ShapeRenderingContext.java | 30 +++++++++++-------- .../codegen/renderer/TemplateRenderer.java | 10 ++++--- .../lambdas/TemplateRenderingLambda.java | 2 +- .../lambdas/TypeSerializerLambda.java | 4 +-- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java b/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java index 6785226d0c..115408b25e 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/Main.java @@ -89,10 +89,10 @@ public static void main(String[] args) { try ( var ctx = ShapeRenderingContext.builder() - .withOutputDir(rootPackageOutputDir) - .withJavaCodeFormatter(b -> b.withRootDir(rootPackageOutputDir.toPath()).withEclipseFormatterConfig(eclipseConfig)) - .withTemplateLoader(b -> b.withTemplatesResourceSubPath("/org/opensearch/client/codegen/templates")) - .build() + .withOutputDir(rootPackageOutputDir) + .withJavaCodeFormatter(b -> b.withRootDir(rootPackageOutputDir.toPath()).withEclipseFormatterConfig(eclipseConfig)) + .withTemplateLoader(b -> b.withTemplatesResourceSubPath("/org/opensearch/client/codegen/templates")) + .build() ) { root.render(ctx); } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ShapeRenderingContext.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ShapeRenderingContext.java index 14d81314cb..0a99f20042 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ShapeRenderingContext.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ShapeRenderingContext.java @@ -36,11 +36,10 @@ private ShapeRenderingContext(Builder builder) { @Nonnull public ShapeRenderingContext forSubDir(@Nonnull String name) { - return builder() - .withOutputDir(new File(outputDir, Strings.requireNonBlank(name, "name must not be null"))) - .withTemplateLoader(templateLoader) - .withJavaCodeFormatter(javaCodeFormatter) - .build(); + return builder().withOutputDir(new File(outputDir, Strings.requireNonBlank(name, "name must not be null"))) + .withTemplateLoader(templateLoader) + .withJavaCodeFormatter(javaCodeFormatter) + .build(); } @Nonnull @@ -50,12 +49,14 @@ public File getOutputFile(@Nonnull String name) { } @Nonnull - public TemplateRenderer getTemplateRenderer(@Nonnull Function valueFormatterConfigurator) { + public TemplateRenderer getTemplateRenderer( + @Nonnull Function valueFormatterConfigurator + ) { return TemplateRenderer.builder() - .withValueFormatter(valueFormatterConfigurator) - .withTemplateLoader(templateLoader) - .withJavaCodeFormatter(javaCodeFormatter) - .build(); + .withValueFormatter(valueFormatterConfigurator) + .withTemplateLoader(templateLoader) + .withJavaCodeFormatter(javaCodeFormatter) + .build(); } @Override @@ -90,7 +91,9 @@ public Builder withTemplateLoader(@Nonnull TemplateLoader templateLoader) { @Nonnull public Builder withTemplateLoader(@Nonnull Function configurator) { - return withTemplateLoader(Objects.requireNonNull(configurator, "configurator must not be null").apply(TemplateLoader.builder()).build()); + return withTemplateLoader( + Objects.requireNonNull(configurator, "configurator must not be null").apply(TemplateLoader.builder()).build() + ); } @Nonnull @@ -110,7 +113,10 @@ public Builder withJavaCodeFormatter(@Nonnull JavaCodeFormatter javaCodeFormatte @Nonnull public Builder withJavaCodeFormatter(@Nonnull Function configurator) { - return withJavaCodeFormatter(Objects.requireNonNull(configurator, "configurator must not be null").apply(JavaCodeFormatter.builder()).build(), true); + return withJavaCodeFormatter( + Objects.requireNonNull(configurator, "configurator must not be null").apply(JavaCodeFormatter.builder()).build(), + true + ); } @Nonnull diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateRenderer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateRenderer.java index bad84fa5ce..e957c528d9 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateRenderer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateRenderer.java @@ -37,9 +37,9 @@ public final class TemplateRenderer { private TemplateRenderer(@Nonnull Builder builder) { Objects.requireNonNull(builder, "builder must not be null"); this.compiler = Mustache.compiler() - .escapeHTML(false) - .withLoader(Objects.requireNonNull(builder.templateLoader, "templateLoader must not be null")) - .withFormatter(Objects.requireNonNull(builder.valueFormatter, "valueFormatter must not be null")); + .escapeHTML(false) + .withLoader(Objects.requireNonNull(builder.templateLoader, "templateLoader must not be null")) + .withFormatter(Objects.requireNonNull(builder.valueFormatter, "valueFormatter must not be null")); this.context = TemplateGlobalContext.builder().withRenderer(this).build(); this.javaCodeFormatter = Objects.requireNonNull(builder.javaCodeFormatter, "javaCodeFormatter must not be null"); } @@ -89,7 +89,9 @@ public static final class Builder { @Nonnull public Builder withValueFormatter(@Nonnull Function configurator) { - this.valueFormatter = Objects.requireNonNull(configurator, "configurator must not be null").apply(TemplateValueFormatter.builder()).build(); + this.valueFormatter = Objects.requireNonNull(configurator, "configurator must not be null") + .apply(TemplateValueFormatter.builder()) + .build(); return this; } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/lambdas/TemplateRenderingLambda.java b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/lambdas/TemplateRenderingLambda.java index 32edd6b6db..18df162e4e 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/lambdas/TemplateRenderingLambda.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/lambdas/TemplateRenderingLambda.java @@ -14,8 +14,8 @@ import java.io.Writer; import javax.annotation.Nonnull; import org.opensearch.client.codegen.exceptions.RenderException; -import org.opensearch.client.codegen.renderer.TemplateGlobalContext; import org.opensearch.client.codegen.renderer.TemplateFragmentUtils; +import org.opensearch.client.codegen.renderer.TemplateGlobalContext; import org.opensearch.client.codegen.utils.Strings; public abstract class TemplateRenderingLambda implements Mustache.Lambda { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/lambdas/TypeSerializerLambda.java b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/lambdas/TypeSerializerLambda.java index b2559f98ba..c8c2f1c14d 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/lambdas/TypeSerializerLambda.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/lambdas/TypeSerializerLambda.java @@ -26,9 +26,7 @@ public TypeSerializerLambda(Type type, boolean direct) { @Override public Object getContext(Template.Fragment fragment) { - var depth = TemplateFragmentUtils.findParentContext(fragment, Context.class) - .map(ctx -> ctx.depth + 1) - .orElse(0); + var depth = TemplateFragmentUtils.findParentContext(fragment, Context.class).map(ctx -> ctx.depth + 1).orElse(0); return new Context(type, fragment.execute(), depth); }