Skip to content

Commit

Permalink
Generate toBuilder and Builder.copy methods
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Nov 19, 2024
1 parent 6c3e68f commit b92bc1d
Show file tree
Hide file tree
Showing 266 changed files with 8,343 additions and 580 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
protected abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<BuilderT>> extends ObjectBuilderBase {
private Boolean acknowledged;

protected AbstractBuilder() {}

protected AbstractBuilder(AcknowledgedResponseBase o) {
this.acknowledged = o.acknowledged;
}

protected AbstractBuilder(AbstractBuilder<BuilderT> o) {
this.acknowledged = o.acknowledged;
}

protected abstract BuilderT self();

/**
* Required - For a successful response, this value is always true. On failure, an exception is returned instead.
* <p>
Expand All @@ -99,7 +111,6 @@ public final BuilderT acknowledged(boolean value) {
return self();
}

protected abstract BuilderT self();
}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,28 @@ protected abstract static class AbstractBuilder<BuilderT extends AbstractBuilder
@Nullable
private String transportAddress;

protected AbstractBuilder() {}

protected AbstractBuilder(BaseNode o) {
this.attributes = _mapCopy(o.attributes);
this.host = o.host;
this.ip = o.ip;
this.name = o.name;
this.roles = _listCopy(o.roles);
this.transportAddress = o.transportAddress;
}

protected AbstractBuilder(AbstractBuilder<BuilderT> o) {
this.attributes = _mapCopy(o.attributes);
this.host = o.host;
this.ip = o.ip;
this.name = o.name;
this.roles = _listCopy(o.roles);
this.transportAddress = o.transportAddress;
}

protected abstract BuilderT self();

/**
* API name: {@code attributes}
*
Expand Down Expand Up @@ -276,7 +298,6 @@ public final BuilderT transportAddress(@Nullable String value) {
return self();
}

protected abstract BuilderT self();
}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Generated;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
Expand Down Expand Up @@ -195,6 +196,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

// ---------------------------------------------------------------------------------------------

@Nonnull
public Builder toBuilder() {
return new Builder(this);
}

@Nonnull
public static Builder builder() {
return new Builder();
}

/**
* Builder for {@link BulkByScrollFailure}.
*/
Expand All @@ -213,6 +224,33 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder<B
private Integer shard;
private Integer status;

public Builder() {}

private Builder(BulkByScrollFailure o) {
this.cause = o.cause;
this.id = o.id;
this.index = o.index;
this.node = o.node;
this.reason = o.reason;
this.shard = o.shard;
this.status = o.status;
}

private Builder(Builder o) {
this.cause = o.cause;
this.id = o.id;
this.index = o.index;
this.node = o.node;
this.reason = o.reason;
this.shard = o.shard;
this.status = o.status;
}

@Nonnull
public Builder copy() {
return new Builder(this);
}

/**
* API name: {@code cause}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

// ---------------------------------------------------------------------------------------------

@Nonnull
public Builder toBuilder() {
return new Builder(this);
}

@Nonnull
public static Builder builder() {
return new Builder();
}

/**
* Builder for {@link BulkByScrollTaskStatus}.
*/
Expand Down Expand Up @@ -376,6 +386,51 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder<B
private Long updated;
private Long versionConflicts;

public Builder() {}

private Builder(BulkByScrollTaskStatus o) {
this.batches = o.batches;
this.canceled = o.canceled;
this.created = o.created;
this.deleted = o.deleted;
this.noops = o.noops;
this.requestsPerSecond = o.requestsPerSecond;
this.retries = o.retries;
this.sliceId = o.sliceId;
this.slices = _listCopy(o.slices);
this.throttled = o.throttled;
this.throttledMillis = o.throttledMillis;
this.throttledUntil = o.throttledUntil;
this.throttledUntilMillis = o.throttledUntilMillis;
this.total = o.total;
this.updated = o.updated;
this.versionConflicts = o.versionConflicts;
}

private Builder(Builder o) {
this.batches = o.batches;
this.canceled = o.canceled;
this.created = o.created;
this.deleted = o.deleted;
this.noops = o.noops;
this.requestsPerSecond = o.requestsPerSecond;
this.retries = o.retries;
this.sliceId = o.sliceId;
this.slices = _listCopy(o.slices);
this.throttled = o.throttled;
this.throttledMillis = o.throttledMillis;
this.throttledUntil = o.throttledUntil;
this.throttledUntilMillis = o.throttledUntilMillis;
this.total = o.total;
this.updated = o.updated;
this.versionConflicts = o.versionConflicts;
}

@Nonnull
public Builder copy() {
return new Builder(this);
}

/**
* Required - The number of scroll responses pulled back by the reindex operation.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

// ---------------------------------------------------------------------------------------------

@Nonnull
public Builder toBuilder() {
return new Builder(this);
}

@Nonnull
public static Builder builder() {
return new Builder();
}

/**
* Builder for {@link ErrorCause}.
*/
Expand All @@ -236,6 +246,33 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder<E
@Nullable
private Map<String, JsonData> metadata;

public Builder() {}

private Builder(ErrorCause o) {
this.causedBy = o.causedBy;
this.reason = o.reason;
this.rootCause = _listCopy(o.rootCause);
this.stackTrace = o.stackTrace;
this.suppressed = _listCopy(o.suppressed);
this.type = o.type;
this.metadata = _mapCopy(o.metadata);
}

private Builder(Builder o) {
this.causedBy = o.causedBy;
this.reason = o.reason;
this.rootCause = _listCopy(o.rootCause);
this.stackTrace = o.stackTrace;
this.suppressed = _listCopy(o.suppressed);
this.type = o.type;
this.metadata = _mapCopy(o.metadata);
}

@Nonnull
public Builder copy() {
return new Builder(this);
}

/**
* API name: {@code caused_by}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,37 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

// ---------------------------------------------------------------------------------------------

@Nonnull
public Builder toBuilder() {
return new Builder(this);
}

@Nonnull
public static Builder builder() {
return new Builder();
}

/**
* Builder for {@link GeoHashLocation}.
*/
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<GeoHashLocation> {
private String geohash;

public Builder() {}

private Builder(GeoHashLocation o) {
this.geohash = o.geohash;
}

private Builder(Builder o) {
this.geohash = o.geohash;
}

@Nonnull
public Builder copy() {
return new Builder(this);
}

/**
* Required - API name: {@code geohash}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ protected abstract static class AbstractBuilder<BuilderT extends AbstractBuilder
@Nullable
private ShardStatistics shards;

protected AbstractBuilder() {}

protected AbstractBuilder(IndicesResponseBase o) {
super(o);
this.shards = o.shards;
}

protected AbstractBuilder(AbstractBuilder<BuilderT> o) {
super(o);
this.shards = o.shards;
}

/**
* API name: {@code _shards}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

// ---------------------------------------------------------------------------------------------

@Nonnull
public Builder toBuilder() {
return new Builder(this);
}

@Nonnull
public static Builder builder() {
return new Builder();
}

/**
* Builder for {@link InlineScript}.
*/
Expand All @@ -139,6 +149,32 @@ public static class Builder extends ScriptBase.AbstractBuilder<Builder> implemen
private Map<String, String> options;
private String source;

public Builder() {}

private Builder(InlineScript o) {
super(o);
this.lang = o.lang;
this.options = _mapCopy(o.options);
this.source = o.source;
}

private Builder(Builder o) {
super(o);
this.lang = o.lang;
this.options = _mapCopy(o.options);
this.source = o.source;
}

@Nonnull
public Builder copy() {
return new Builder(this);
}

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

/**
* API name: {@code lang}
*/
Expand Down Expand Up @@ -189,11 +225,6 @@ public final Builder source(String value) {
return this;
}

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

/**
* Builds a {@link InlineScript}.
*
Expand Down
Loading

0 comments on commit b92bc1d

Please sign in to comment.