Skip to content

Commit

Permalink
Implementing PlainDeserializable for free-formed parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Jai2305 <[email protected]>
  • Loading branch information
Jai2305 committed Sep 1, 2024
1 parent c101485 commit 8bb2517
Show file tree
Hide file tree
Showing 26 changed files with 50 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public interface PlainDeserializable<B> {

B get();
B self();

/** Updates object with newly provided JSON properties
@param parser the JsonParser parser
Expand All @@ -29,7 +29,7 @@ default B withJson(JsonParser parser, JsonpMapper mapper) {
@SuppressWarnings("unchecked")
ObjectDeserializer<B> objectDeserializer = (ObjectDeserializer<B>) DelegatingDeserializer.unwrap(deserializer);
assert objectDeserializer != null;
return objectDeserializer.deserialize(get(), parser, mapper, parser.next());
return objectDeserializer.deserialize(self(), parser, mapper, parser.next());
}

/** Updates object with newly provided JSON properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainDeserializable;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.util.ApiTypeHelper;
import org.opensearch.client.util.ObjectBuilder;
Expand Down Expand Up @@ -172,7 +173,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
* Builder for {@link SourceField}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<SourceField> {
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<SourceField>, PlainDeserializable<Builder> {
@Nullable
private Boolean compress;

Expand Down Expand Up @@ -263,6 +264,11 @@ public SourceField build() {

return new SourceField(this);
}

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

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainDeserializable;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.util.ApiTypeHelper;
import org.opensearch.client.util.ObjectBuilder;
Expand Down Expand Up @@ -363,7 +364,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
* Builder for {@link TypeMapping}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<TypeMapping> {
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<TypeMapping>, PlainDeserializable<Builder> {
@Nullable
private AllField allField;

Expand Down Expand Up @@ -660,6 +661,11 @@ public TypeMapping build() {

return new TypeMapping(this);
}

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

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public AllocationExplainRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public PutClusterSettingsRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ public PutComponentTemplateRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public RerouteRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public ClearScrollRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ public DeleteByQueryRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ public ExplainRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public PutScriptRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ public ReindexRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public RenderSearchTemplateRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public ScrollRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2249,7 +2249,7 @@ public SearchRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ public SearchTemplateRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ public UpdateByQueryRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public CloneIndexRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public CreateIndexRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainDeserializable;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.opensearch._types.Time;
import org.opensearch.client.util.ApiTypeHelper;
Expand Down Expand Up @@ -1108,7 +1109,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
* Builder for {@link IndexSettings}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<IndexSettings> {
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<IndexSettings>, PlainDeserializable<Builder> {
@Nullable
private IndexSettings index;

Expand Down Expand Up @@ -1919,6 +1920,10 @@ public final Builder knnAlgoParamEfSearch(@Nullable Integer value) {
return this;
}

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

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public PutIndexTemplateRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ public PutTemplateRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public UpdateAliasesRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainDeserializable;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.opensearch._types.mapping.TypeMapping;
import org.opensearch.client.opensearch.indices.Alias;
Expand Down Expand Up @@ -139,7 +140,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
* Builder for {@link IndexTemplateMapping}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<IndexTemplateMapping> {
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<IndexTemplateMapping>, PlainDeserializable<Builder> {
@Nullable
private Map<String, Alias> aliases;

Expand Down Expand Up @@ -219,6 +220,11 @@ public IndexTemplateMapping build() {

return new IndexTemplateMapping(this);
}

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

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public ReloadSecureSettingsRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public CreateSnapshotRequest build() {
}

@Override
public Builder get() {
public Builder self() {
return this;
}
}
Expand Down

0 comments on commit 8bb2517

Please sign in to comment.