Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Aug 29, 2024
1 parent bcefe6d commit ecdb6ff
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -84,7 +83,7 @@ private Builder() {
}

@Override
protected @NotNull Builder self() {
protected @Nonnull Builder self() {
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,22 +47,22 @@ public static Builder builder() {
}

@Nullable
private final String package_;
private final String packageName;
@Nonnull
private final String name;
@Nullable
private final Type[] typeParams;
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
Expand Down Expand Up @@ -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() {
Expand All @@ -190,9 +189,9 @@ public Mustache.Lambda directSerializer() {
}

public void getRequiredImports(Set<String> 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) {
Expand All @@ -214,7 +213,7 @@ public Mustache.Lambda isDefined() {
}

public static final class Builder extends ObjectBuilderBase<Type, Builder> {
private String package_;
private String packageName;
private String name;
private Type[] typeParams;
private boolean isEnum;
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@

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;

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
Expand All @@ -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() {
Expand All @@ -46,14 +45,14 @@ public static Builder builder() {

public static final class Builder extends ObjectBuilderBase<TypeParameterDefinition, Builder> {
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;
}

Expand All @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -360,7 +359,7 @@ private Builder() {
}

@Override
protected @NotNull Builder self() {
protected @Nonnull Builder self() {
return this;
}

Expand Down

0 comments on commit ecdb6ff

Please sign in to comment.