From ecdb6ffc6d80a39742e99ddbbf13edad4395aa9c Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 30 Aug 2024 09:36:43 +1200 Subject: [PATCH] Address review comments Signed-off-by: Thomas Farr --- .../codegen/model/ShapeRenderingContext.java | 3 +-- .../opensearch/client/codegen/model/Type.java | 21 +++++++++---------- .../model/TypeParameterDefinition.java | 15 +++++++------ .../client/codegen/openapi/OpenApiSchema.java | 3 +-- 4 files changed, 19 insertions(+), 23 deletions(-) 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 7e14698668..097dee806c 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 @@ -12,7 +12,6 @@ import java.util.Objects; import java.util.function.Function; import javax.annotation.Nonnull; -import org.jetbrains.annotations.NotNull; import org.opensearch.client.codegen.renderer.JavaCodeFormatter; import org.opensearch.client.codegen.renderer.TemplateLoader; import org.opensearch.client.codegen.renderer.TemplateRenderer; @@ -84,7 +83,7 @@ private Builder() { } @Override - protected @NotNull Builder self() { + protected @Nonnull Builder self() { return this; } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java index 9c1db57814..18f5eee2d1 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java @@ -15,7 +15,6 @@ import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.qual.NonNull; import org.opensearch.client.codegen.renderer.lambdas.TypeIsDefinedLambda; import org.opensearch.client.codegen.renderer.lambdas.TypeQueryParamifyLambda; import org.opensearch.client.codegen.renderer.lambdas.TypeSerializerLambda; @@ -48,7 +47,7 @@ public static Builder builder() { } @Nullable - private final String package_; + private final String packageName; @Nonnull private final String name; @Nullable @@ -56,14 +55,14 @@ public static Builder builder() { private final boolean isEnum; private Type(Builder builder) { - this.package_ = builder.package_; + this.packageName = builder.packageName; this.name = Strings.requireNonBlank(builder.name, "name must not be blank"); this.typeParams = builder.typeParams; this.isEnum = builder.isEnum; } public Builder toBuilder() { - return new Builder().withPackage(package_).withName(name).withTypeParameters(typeParams).isEnum(isEnum); + return new Builder().withPackage(packageName).withName(name).withTypeParameters(typeParams).isEnum(isEnum); } @Override @@ -178,7 +177,7 @@ public Type getBuilderFnType() { } public Type getNestedType(String name) { - return builder().withPackage(package_).withName(this.name + "." + name).build(); + return builder().withPackage(packageName).withName(this.name + "." + name).build(); } public Mustache.Lambda serializer() { @@ -190,9 +189,9 @@ public Mustache.Lambda directSerializer() { } public void getRequiredImports(Set imports, String currentPkg) { - if (package_ != null && !package_.equals(Java.Lang.PACKAGE) && !package_.equals(currentPkg)) { + if (packageName != null && !packageName.equals(Java.Lang.PACKAGE) && !packageName.equals(currentPkg)) { var dotIdx = name.indexOf('.'); - imports.add(package_ + '.' + (dotIdx > 0 ? name.substring(0, dotIdx) : name)); + imports.add(packageName + '.' + (dotIdx > 0 ? name.substring(0, dotIdx) : name)); } if (typeParams != null) { for (Type arg : typeParams) { @@ -214,7 +213,7 @@ public Mustache.Lambda isDefined() { } public static final class Builder extends ObjectBuilderBase { - private String package_; + private String packageName; private String name; private Type[] typeParams; private boolean isEnum; @@ -224,13 +223,13 @@ private Builder() { } @Override - protected @NonNull Builder self() { + protected @Nonnull Builder self() { return this; } @Nonnull - public Builder withPackage(@Nullable String package_) { - this.package_ = package_; + public Builder withPackage(@Nullable String packageName) { + this.packageName = packageName; return this; } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/TypeParameterDefinition.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/TypeParameterDefinition.java index 991bcbc1ec..1fb3e9d656 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/TypeParameterDefinition.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/TypeParameterDefinition.java @@ -10,7 +10,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.jetbrains.annotations.NotNull; import org.opensearch.client.codegen.utils.ObjectBuilderBase; import org.opensearch.client.codegen.utils.Strings; @@ -18,11 +17,11 @@ public final class TypeParameterDefinition { @Nonnull private final String name; @Nullable - private final Type extends_; + private final Type extendsType; private TypeParameterDefinition(Builder builder) { this.name = Strings.requireNonBlank(builder.name, "name must not be blank"); - this.extends_ = builder.extends_; + this.extendsType = builder.extendsType; } @Nonnull @@ -32,12 +31,12 @@ public String getName() { @Nullable public Type getExtends() { - return extends_; + return extendsType; } @Override public String toString() { - return name + (extends_ != null ? " extends " + extends_ : ""); + return name + (extendsType != null ? " extends " + extendsType : ""); } public static Builder builder() { @@ -46,14 +45,14 @@ public static Builder builder() { public static final class Builder extends ObjectBuilderBase { private String name; - private Type extends_; + private Type extendsType; private Builder() { super(TypeParameterDefinition::new); } @Override - protected @NotNull Builder self() { + protected @Nonnull Builder self() { return this; } @@ -65,7 +64,7 @@ public Builder withName(@Nonnull String name) { @Nonnull public Builder withExtends(@Nullable Type type) { - this.extends_ = type; + this.extendsType = type; return this; } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java index 980145a4be..b301160c53 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java @@ -21,7 +21,6 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.jetbrains.annotations.NotNull; import org.opensearch.client.codegen.utils.Lists; import org.opensearch.client.codegen.utils.Maps; import org.opensearch.client.codegen.utils.ObjectBuilderBase; @@ -360,7 +359,7 @@ private Builder() { } @Override - protected @NotNull Builder self() { + protected @Nonnull Builder self() { return this; }