Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Jun 10, 2024
1 parent 996a379 commit 5120a6b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -50,12 +49,14 @@ public File getOutputFile(@Nonnull String name) {
}

@Nonnull
public TemplateRenderer getTemplateRenderer(@Nonnull Function<TemplateValueFormatter.Builder, TemplateValueFormatter.Builder> valueFormatterConfigurator) {
public TemplateRenderer getTemplateRenderer(
@Nonnull Function<TemplateValueFormatter.Builder, TemplateValueFormatter.Builder> valueFormatterConfigurator
) {
return TemplateRenderer.builder()
.withValueFormatter(valueFormatterConfigurator)
.withTemplateLoader(templateLoader)
.withJavaCodeFormatter(javaCodeFormatter)
.build();
.withValueFormatter(valueFormatterConfigurator)
.withTemplateLoader(templateLoader)
.withJavaCodeFormatter(javaCodeFormatter)
.build();
}

@Override
Expand Down Expand Up @@ -90,7 +91,9 @@ public Builder withTemplateLoader(@Nonnull TemplateLoader templateLoader) {

@Nonnull
public Builder withTemplateLoader(@Nonnull Function<TemplateLoader.Builder, TemplateLoader.Builder> 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
Expand All @@ -110,7 +113,10 @@ public Builder withJavaCodeFormatter(@Nonnull JavaCodeFormatter javaCodeFormatte

@Nonnull
public Builder withJavaCodeFormatter(@Nonnull Function<JavaCodeFormatter.Builder, JavaCodeFormatter.Builder> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -89,7 +89,9 @@ public static final class Builder {

@Nonnull
public Builder withValueFormatter(@Nonnull Function<TemplateValueFormatter.Builder, TemplateValueFormatter.Builder> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 5120a6b

Please sign in to comment.