From a981eb7311ec0807f848eb54ff48c8e8c9e56642 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Wed, 2 Oct 2024 10:05:19 +1300 Subject: [PATCH 1/2] Generate hashCode and equals (#1201) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Generate hashCode and equals , wip Signed-off-by: miguel-vila * add changelog entry Signed-off-by: miguel-vila * remove change Signed-off-by: miguel-vila * take into account primitives Signed-off-by: miguel-vila * refactor and format Signed-off-by: miguel-vila * use Object.equals Co-authored-by: Thomas Farr Signed-off-by: Miguel Vilá * use `&&` chain Signed-off-by: miguel-vila * adjust last line Signed-off-by: miguel-vila * use fqn Signed-off-by: miguel-vila * use fqn for Objects.hashCode, take into account parent Signed-off-by: miguel-vila * remove unused var definition Signed-off-by: miguel-vila * codegen equals/hashCode for request shapes Signed-off-by: miguel-vila * add hashCode/equals to TaggedUnion Signed-off-by: miguel-vila * use import Signed-off-by: miguel-vila * fix equals for request shapes Signed-off-by: miguel-vila * codegen latest from main Signed-off-by: miguel-vila --------- Signed-off-by: miguel-vila Signed-off-by: Miguel Vilá Co-authored-by: Thomas Farr Signed-off-by: Thomas Farr (cherry picked from commit 18a84604c74c945c2a08e1228b89b04d64d0db5e) --- CHANGELOG.md | 1 + .../client/opensearch/_types/ErrorCause.java | 26 +++++++++++++++ .../opensearch/_types/ShardFailure.java | 22 +++++++++++++ .../opensearch/_types/ShardStatistics.java | 22 +++++++++++++ .../opensearch/_types/WriteResponseBase.java | 28 ++++++++++++++++ .../client/opensearch/ml/Action.java | 26 +++++++++++++++ .../client/opensearch/ml/ClientConfig.java | 26 +++++++++++++++ .../opensearch/ml/CreateConnectorRequest.java | 28 ++++++++++++++++ .../ml/CreateConnectorResponse.java | 14 ++++++++ .../client/opensearch/ml/Credential.java | 20 ++++++++++++ .../opensearch/ml/DeleteAgentRequest.java | 14 ++++++++ .../opensearch/ml/DeleteAgentResponse.java | 14 ++++++++ .../opensearch/ml/DeleteConnectorRequest.java | 14 ++++++++ .../ml/DeleteConnectorResponse.java | 14 ++++++++ .../ml/DeleteModelGroupRequest.java | 14 ++++++++ .../ml/DeleteModelGroupResponse.java | 14 ++++++++ .../opensearch/ml/DeleteModelRequest.java | 14 ++++++++ .../opensearch/ml/DeleteModelResponse.java | 14 ++++++++ .../opensearch/ml/DeleteTaskRequest.java | 14 ++++++++ .../opensearch/ml/DeleteTaskResponse.java | 14 ++++++++ .../opensearch/ml/DeployModelRequest.java | 14 ++++++++ .../opensearch/ml/DeployModelResponse.java | 18 +++++++++++ .../opensearch/ml/GetModelGroupRequest.java | 14 ++++++++ .../opensearch/ml/GetModelGroupResponse.java | 24 ++++++++++++++ .../client/opensearch/ml/GetTaskRequest.java | 14 ++++++++ .../client/opensearch/ml/GetTaskResponse.java | 32 +++++++++++++++++++ .../client/opensearch/ml/Headers.java | 15 +++++++++ .../opensearch/client/opensearch/ml/LLM.java | 15 +++++++++ .../client/opensearch/ml/Memory.java | 14 ++++++++ .../opensearch/ml/RegisterAgentsRequest.java | 28 ++++++++++++++++ .../opensearch/ml/RegisterAgentsResponse.java | 14 ++++++++ .../ml/RegisterModelGroupRequest.java | 22 +++++++++++++ .../ml/RegisterModelGroupResponse.java | 15 +++++++++ .../opensearch/ml/RegisterModelRequest.java | 22 +++++++++++++ .../opensearch/ml/RegisterModelResponse.java | 15 +++++++++ .../client/opensearch/ml/ToolItems.java | 20 ++++++++++++ .../opensearch/ml/UndeployModelNode.java | 14 ++++++++ .../opensearch/ml/UndeployModelRequest.java | 14 ++++++++ .../opensearch/ml/UndeployModelResponse.java | 14 ++++++++ .../client/codegen/model/Field.java | 8 +++++ .../client/codegen/model/ObjectShape.java | 4 +++ .../client/codegen/model/RequestShape.java | 4 +++ .../opensearch/client/codegen/model/Type.java | 12 +++++++ .../client/codegen/model/Types.java | 1 + .../codegen/templates/ObjectShape.mustache | 6 +++- .../templates/ObjectShape/Equals.mustache | 27 ++++++++++++++++ .../templates/ObjectShape/HashCode.mustache | 22 +++++++++++++ .../ObjectShape/TaggedUnionEquals.mustache | 6 ++++ .../ObjectShape/TaggedUnionHashCode.mustache | 6 ++++ .../codegen/templates/RequestShape.mustache | 6 +++- .../templates/TaggedUnionShape.mustache | 5 +++ 51 files changed, 796 insertions(+), 2 deletions(-) create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Equals.mustache create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/HashCode.mustache create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionEquals.mustache create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionHashCode.mustache diff --git a/CHANGELOG.md b/CHANGELOG.md index 57d3fd71b5..4687e56ca3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased 2.x] ### Added +- Add `hashCode` and `equals` implementations ([#312](https://github.com/opensearch-project/opensearch-java/pull/312)). ### Dependencies - Bumps `org.junit:junit-bom` from 5.10.3 to 5.11.1 diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java index c029456c39..de1cad3599 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java @@ -40,6 +40,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import javax.annotation.Nullable; @@ -404,4 +405,29 @@ protected static void setupErrorCauseDeserializer(ObjectDeserializer> void setupWriteRes op.add(AbstractBuilder::shards, ShardStatistics._DESERIALIZER, "_shards"); op.add(AbstractBuilder::version, JsonpDeserializer.longDeserializer(), "_version"); } + + public int hashCode() { + int result = 17; + result = 31 * result + Boolean.hashCode(this.forcedRefresh); + result = 31 * result + this.id.hashCode(); + result = 31 * result + this.index.hashCode(); + result = 31 * result + Long.hashCode(this.primaryTerm); + result = 31 * result + this.result.hashCode(); + result = 31 * result + Long.hashCode(this.seqNo); + result = 31 * result + this.shards.hashCode(); + result = 31 * result + Long.hashCode(this.version); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + WriteResponseBase other = (WriteResponseBase) o; + return this.forcedRefresh() == other.forcedRefresh() + && Objects.equals(this.id, other.id) + && Objects.equals(this.index, other.index) + && this.primaryTerm() == other.primaryTerm() + && Objects.equals(this.result, other.result) + && this.seqNo() == other.seqNo() + && Objects.equals(this.shards, other.shards) + && this.version() == other.version(); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Action.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Action.java index e9912634cc..68e20bc646 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Action.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Action.java @@ -13,6 +13,7 @@ package org.opensearch.client.opensearch.ml; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import javax.annotation.Nullable; @@ -286,4 +287,29 @@ protected static void setupActionDeserializer(ObjectDeserializer op.add(Builder::requestBody, JsonpDeserializer.stringDeserializer(), "request_body"); op.add(Builder::url, JsonpDeserializer.stringDeserializer(), "url"); } + + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.actionType); + result = 31 * result + Objects.hashCode(this.headers); + result = 31 * result + Objects.hashCode(this.method); + result = 31 * result + Objects.hashCode(this.postProcessFunction); + result = 31 * result + Objects.hashCode(this.preProcessFunction); + result = 31 * result + Objects.hashCode(this.requestBody); + result = 31 * result + Objects.hashCode(this.url); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + Action other = (Action) o; + return Objects.equals(this.actionType, other.actionType) + && Objects.equals(this.headers, other.headers) + && Objects.equals(this.method, other.method) + && Objects.equals(this.postProcessFunction, other.postProcessFunction) + && Objects.equals(this.preProcessFunction, other.preProcessFunction) + && Objects.equals(this.requestBody, other.requestBody) + && Objects.equals(this.url, other.url); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/ClientConfig.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/ClientConfig.java index e3907e7f59..0a3fa1a853 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/ClientConfig.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/ClientConfig.java @@ -13,6 +13,7 @@ package org.opensearch.client.opensearch.ml; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import javax.annotation.Nullable; @@ -279,4 +280,29 @@ protected static void setupClientConfigDeserializer(ObjectDeserializer op) { op.add(Builder::connectorId, JsonpDeserializer.stringDeserializer(), "connector_id"); } + + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.connectorId); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + CreateConnectorResponse other = (CreateConnectorResponse) o; + return Objects.equals(this.connectorId, other.connectorId); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Credential.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Credential.java index 8e32830e5e..1e465e9f59 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Credential.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Credential.java @@ -15,6 +15,7 @@ import jakarta.json.stream.JsonGenerator; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import javax.annotation.Nullable; @@ -214,4 +215,23 @@ protected static void setupCredentialDeserializer(ObjectDeserializer op) { WriteResponseBase.setupWriteResponseBaseDeserializer(op); } + + public int hashCode() { + int result = super.hashCode(); + return result; + } + + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + return true; + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorRequest.java index 30e0f7d202..b108f9b63e 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorRequest.java @@ -12,6 +12,7 @@ package org.opensearch.client.opensearch.ml; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import org.opensearch.client.opensearch._types.ErrorResponse; @@ -98,4 +99,17 @@ public DeleteConnectorRequest build() { false, DeleteConnectorResponse._DESERIALIZER ); + + public int hashCode() { + int result = 17; + result = 31 * result + this.connectorId.hashCode(); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + DeleteConnectorRequest other = (DeleteConnectorRequest) o; + return Objects.equals(this.connectorId, other.connectorId); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorResponse.java index 1ba0900cc8..9119d195e6 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorResponse.java @@ -73,4 +73,18 @@ public DeleteConnectorResponse build() { protected static void setupDeleteConnectorResponseDeserializer(ObjectDeserializer op) { WriteResponseBase.setupWriteResponseBaseDeserializer(op); } + + public int hashCode() { + int result = super.hashCode(); + return result; + } + + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + return true; + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupRequest.java index 181a605275..7575637baf 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupRequest.java @@ -12,6 +12,7 @@ package org.opensearch.client.opensearch.ml; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import org.opensearch.client.opensearch._types.ErrorResponse; @@ -98,4 +99,17 @@ public DeleteModelGroupRequest build() { false, DeleteModelGroupResponse._DESERIALIZER ); + + public int hashCode() { + int result = 17; + result = 31 * result + this.modelGroupId.hashCode(); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + DeleteModelGroupRequest other = (DeleteModelGroupRequest) o; + return Objects.equals(this.modelGroupId, other.modelGroupId); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupResponse.java index 742257bf99..5315f6739b 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupResponse.java @@ -73,4 +73,18 @@ public DeleteModelGroupResponse build() { protected static void setupDeleteModelGroupResponseDeserializer(ObjectDeserializer op) { WriteResponseBase.setupWriteResponseBaseDeserializer(op); } + + public int hashCode() { + int result = super.hashCode(); + return result; + } + + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + return true; + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelRequest.java index f9be99c118..f14d9eb0cd 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelRequest.java @@ -12,6 +12,7 @@ package org.opensearch.client.opensearch.ml; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import org.opensearch.client.opensearch._types.ErrorResponse; @@ -98,4 +99,17 @@ public DeleteModelRequest build() { false, DeleteModelResponse._DESERIALIZER ); + + public int hashCode() { + int result = 17; + result = 31 * result + this.modelId.hashCode(); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + DeleteModelRequest other = (DeleteModelRequest) o; + return Objects.equals(this.modelId, other.modelId); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelResponse.java index 1395e93e08..feb2c322d6 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelResponse.java @@ -73,4 +73,18 @@ public DeleteModelResponse build() { protected static void setupDeleteModelResponseDeserializer(ObjectDeserializer op) { WriteResponseBase.setupWriteResponseBaseDeserializer(op); } + + public int hashCode() { + int result = super.hashCode(); + return result; + } + + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + return true; + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskRequest.java index a378f83fde..9620b90898 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskRequest.java @@ -12,6 +12,7 @@ package org.opensearch.client.opensearch.ml; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import org.opensearch.client.opensearch._types.ErrorResponse; @@ -98,4 +99,17 @@ public DeleteTaskRequest build() { false, DeleteTaskResponse._DESERIALIZER ); + + public int hashCode() { + int result = 17; + result = 31 * result + this.taskId.hashCode(); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + DeleteTaskRequest other = (DeleteTaskRequest) o; + return Objects.equals(this.taskId, other.taskId); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskResponse.java index 93e33ffd2c..ee52e15754 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskResponse.java @@ -73,4 +73,18 @@ public DeleteTaskResponse build() { protected static void setupDeleteTaskResponseDeserializer(ObjectDeserializer op) { WriteResponseBase.setupWriteResponseBaseDeserializer(op); } + + public int hashCode() { + int result = super.hashCode(); + return result; + } + + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + return true; + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelRequest.java index 2230cb1d82..dc823dd744 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelRequest.java @@ -12,6 +12,7 @@ package org.opensearch.client.opensearch.ml; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import org.opensearch.client.opensearch._types.ErrorResponse; @@ -99,4 +100,17 @@ public DeployModelRequest build() { false, DeployModelResponse._DESERIALIZER ); + + public int hashCode() { + int result = 17; + result = 31 * result + this.modelId.hashCode(); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + DeployModelRequest other = (DeployModelRequest) o; + return Objects.equals(this.modelId, other.modelId); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelResponse.java index 23b01f8025..2d436560f4 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelResponse.java @@ -13,6 +13,7 @@ package org.opensearch.client.opensearch.ml; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import javax.annotation.Nullable; @@ -158,4 +159,21 @@ protected static void setupDeployModelResponseDeserializer(ObjectDeserializer op) { op.add(Builder::modelId, JsonpDeserializer.stringDeserializer(), "model_id"); op.add(Builder::parameters, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "parameters"); } + + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.modelId); + result = 31 * result + Objects.hashCode(this.parameters); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + LLM other = (LLM) o; + return Objects.equals(this.modelId, other.modelId) && Objects.equals(this.parameters, other.parameters); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Memory.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Memory.java index dfc0a9083c..3ae6dcaf1e 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Memory.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Memory.java @@ -13,6 +13,7 @@ package org.opensearch.client.opensearch.ml; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import javax.annotation.Nullable; @@ -111,4 +112,17 @@ public Memory build() { protected static void setupMemoryDeserializer(ObjectDeserializer op) { op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); } + + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.type); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + Memory other = (Memory) o; + return Objects.equals(this.type, other.type); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsRequest.java index 155e0de881..1924edac77 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsRequest.java @@ -15,6 +15,7 @@ import jakarta.json.stream.JsonGenerator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import javax.annotation.Nullable; @@ -386,4 +387,31 @@ protected static void setupRegisterAgentsRequestDeserializer(ObjectDeserializer< true, RegisterAgentsResponse._DESERIALIZER ); + + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.appType); + result = 31 * result + Objects.hashCode(this.description); + result = 31 * result + Objects.hashCode(this.llm); + result = 31 * result + Objects.hashCode(this.memory); + result = 31 * result + this.name.hashCode(); + result = 31 * result + Objects.hashCode(this.parameters); + result = 31 * result + Objects.hashCode(this.tools); + result = 31 * result + this.type.hashCode(); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + RegisterAgentsRequest other = (RegisterAgentsRequest) o; + return Objects.equals(this.appType, other.appType) + && Objects.equals(this.description, other.description) + && Objects.equals(this.llm, other.llm) + && Objects.equals(this.memory, other.memory) + && Objects.equals(this.name, other.name) + && Objects.equals(this.parameters, other.parameters) + && Objects.equals(this.tools, other.tools) + && Objects.equals(this.type, other.type); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsResponse.java index e69ff9e0de..199ae5fde6 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsResponse.java @@ -13,6 +13,7 @@ package org.opensearch.client.opensearch.ml; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import javax.annotation.Nullable; @@ -111,4 +112,17 @@ public RegisterAgentsResponse build() { protected static void setupRegisterAgentsResponseDeserializer(ObjectDeserializer op) { op.add(Builder::agentId, JsonpDeserializer.stringDeserializer(), "agent_id"); } + + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.agentId); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + RegisterAgentsResponse other = (RegisterAgentsResponse) o; + return Objects.equals(this.agentId, other.agentId); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java index 2cf102fca7..b9f1b069fd 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java @@ -14,6 +14,7 @@ import jakarta.json.stream.JsonGenerator; import java.util.List; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import javax.annotation.Nullable; @@ -294,4 +295,25 @@ protected static void setupRegisterModelGroupRequestDeserializer(ObjectDeseriali true, RegisterModelGroupResponse._DESERIALIZER ); + + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.accessMode); + result = 31 * result + Boolean.hashCode(this.addAllBackendRoles); + result = 31 * result + Objects.hashCode(this.backendRoles); + result = 31 * result + Objects.hashCode(this.description); + result = 31 * result + this.name.hashCode(); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + RegisterModelGroupRequest other = (RegisterModelGroupRequest) o; + return Objects.equals(this.accessMode, other.accessMode) + && this.addAllBackendRoles() == other.addAllBackendRoles() + && Objects.equals(this.backendRoles, other.backendRoles) + && Objects.equals(this.description, other.description) + && Objects.equals(this.name, other.name); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java index 240993a8c8..6ee1aab4cf 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java @@ -13,6 +13,7 @@ package org.opensearch.client.opensearch.ml; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import org.opensearch.client.json.JsonpDeserializable; @@ -143,4 +144,18 @@ protected static void setupRegisterModelGroupResponseDeserializer(ObjectDeserial op.add(Builder::modelGroupId, JsonpDeserializer.stringDeserializer(), "model_group_id"); op.add(Builder::status, JsonpDeserializer.stringDeserializer(), "status"); } + + public int hashCode() { + int result = 17; + result = 31 * result + this.modelGroupId.hashCode(); + result = 31 * result + this.status.hashCode(); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + RegisterModelGroupResponse other = (RegisterModelGroupResponse) o; + return Objects.equals(this.modelGroupId, other.modelGroupId) && Objects.equals(this.status, other.status); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java index 98fb7909fd..9536644078 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java @@ -13,6 +13,7 @@ package org.opensearch.client.opensearch.ml; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import javax.annotation.Nullable; @@ -262,4 +263,25 @@ protected static void setupRegisterModelRequestDeserializer(ObjectDeserializer op) { op.add(Builder::stats, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "stats"); } + + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.stats); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + UndeployModelNode other = (UndeployModelNode) o; + return Objects.equals(this.stats, other.stats); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelRequest.java index 4ae83cb5b5..0b9f760371 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelRequest.java @@ -12,6 +12,7 @@ package org.opensearch.client.opensearch.ml; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import org.opensearch.client.opensearch._types.ErrorResponse; @@ -99,4 +100,17 @@ public UndeployModelRequest build() { false, UndeployModelResponse._DESERIALIZER ); + + public int hashCode() { + int result = 17; + result = 31 * result + this.modelId.hashCode(); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + UndeployModelRequest other = (UndeployModelRequest) o; + return Objects.equals(this.modelId, other.modelId); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelResponse.java index 83128a460a..74cd159526 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelResponse.java @@ -15,6 +15,7 @@ import jakarta.json.stream.JsonGenerator; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; import javax.annotation.Nullable; @@ -140,4 +141,17 @@ protected static void setupUndeployModelResponseDeserializer(ObjectDeserializer< builder.nodes.put(name, UndeployModelNode._DESERIALIZER.deserialize(parser, mapper)); }); } + + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.nodes); + return result; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (this.getClass() != o.getClass()) return false; + UndeployModelResponse other = (UndeployModelResponse) o; + return Objects.equals(this.nodes, other.nodes); + } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java index e4d1734572..03025401cb 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java @@ -84,4 +84,12 @@ public String getDescription() { public Deprecation getDeprecation() { return deprecation; } + + public boolean isUnboxedPrimitive() { + return type.isUnboxedPrimitive(); + } + + public Type getBoxedType() { + return type.getBoxed(); + } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java index 75b82438f1..32ba374de0 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java @@ -55,6 +55,10 @@ public boolean hasFieldsToSerialize() { return !bodyFields.isEmpty() || additionalPropertiesField != null; } + public boolean hasFields() { + return !bodyFields.isEmpty() || additionalPropertiesField != null; + } + public Collection getImplementsTypes() { return hasFieldsToSerialize() && !extendsOtherShape() ? List.of(Types.Client.Json.PlainJsonSerializable) : null; } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java index 18facfd53e..d76a67d2fe 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java @@ -151,6 +151,10 @@ public boolean hasAnyRequiredFields() { return fields.values().stream().anyMatch(Field::isRequired); } + public boolean hasFields() { + return !fields.isEmpty(); + } + public Type getJsonEndpointType() { return Types.Client.Transport.JsonEndpoint(getType(), getResponseType(), Types.Client.OpenSearch._Types.ErrorResponse); } 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 2e4391b787..d9123a7eaa 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 @@ -157,6 +157,18 @@ public boolean isPrimitive() { return PRIMITIVES.contains(name); } + public boolean isUnboxedPrimitive() { + return isPrimitive() + && !name.equals("String") + && !name.equals("Boolean") + && !name.equals("Character") + && !name.equals("Integer") + && !name.equals("Long") + && !name.equals("Float") + && !name.equals("Double") + && !name.equals("Number"); + } + public boolean isNumber() { return "Number".equals(name); } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java index 8d522a11f1..d5f4e9a750 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java @@ -72,6 +72,7 @@ public static final class Lang { public static final class Util { public static final String PACKAGE = Java.PACKAGE + ".util"; + public static final Type Objects = Type.builder().withPackage(PACKAGE).withName("Objects").build(); public static final Type HashMap = Type.builder().withPackage(PACKAGE).withName("HashMap").build(); public static Type Map(Type keyType, Type valueType) { diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache index 627af1db03..0cd936e3b4 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache @@ -19,4 +19,8 @@ // --------------------------------------------------------------------------------------------- {{>ObjectShape/Deserialize}} -} \ No newline at end of file + + {{>ObjectShape/HashCode}} + + {{>ObjectShape/Equals}} +} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Equals.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Equals.mustache new file mode 100644 index 0000000000..6e45e22d72 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Equals.mustache @@ -0,0 +1,27 @@ + public boolean equals(Object o) { + {{#extendsOtherShape}} + if(!super.equals(o)) { + return false; + } + {{/extendsOtherShape}} + if(this == o) return true; + if(this.getClass() != o.getClass()) return false; + {{^hasFields}} + return true; + {{/hasFields}} + {{#hasFields}} + {{className}} other = ({{className}})o; + return + {{#fields}} + {{#isUnboxedPrimitive}} + this.{{name}}() == other.{{name}}() + {{/isUnboxedPrimitive}} + {{^isUnboxedPrimitive}} + {{TYPES.Java.Util.Objects}}.equals(this.{{name}}, other.{{name}}) + {{/isUnboxedPrimitive}} + {{^-last}} + && + {{/-last}} + {{/fields}}; + {{/hasFields}} + } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/HashCode.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/HashCode.mustache new file mode 100644 index 0000000000..5418321cc6 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/HashCode.mustache @@ -0,0 +1,22 @@ + public int hashCode() { + {{#extendsOtherShape}} + int result = super.hashCode(); + {{/extendsOtherShape}} + {{^extendsOtherShape}} + int result = 17; + {{/extendsOtherShape}} + {{#fields}} + {{#isUnboxedPrimitive}} + result = 31 * result + {{getBoxedType}}.hashCode(this.{{name}}); + {{/isUnboxedPrimitive}} + {{^isUnboxedPrimitive}} + {{#isRequired}} + result = 31 * result + this.{{name}}.hashCode(); + {{/isRequired}} + {{^isRequired}} + result = 31 * result + {{TYPES.Java.Util.Objects}}.hashCode(this.{{name}}); + {{/isRequired}} + {{/isUnboxedPrimitive}} + {{/fields}} + return result; + } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionEquals.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionEquals.mustache new file mode 100644 index 0000000000..7a368dc538 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionEquals.mustache @@ -0,0 +1,6 @@ + public boolean equals(Object o) { + if(this == o) return true; + if(this.getClass() != o.getClass()) return false; + {{className}} other = ({{className}})o; + return this._kind().equals(other._kind()) && this._get().equals(other._get()); + } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionHashCode.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionHashCode.mustache new file mode 100644 index 0000000000..8cd7137529 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionHashCode.mustache @@ -0,0 +1,6 @@ + public int hashCode() { + int result = 17; + result = 31 * result + _kind.hashCode(); + result = 31 * result + _value.hashCode(); + return result; + } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache index 73c0960fea..f73f6dd4a2 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache @@ -96,4 +96,8 @@ {{hasRequestBody}}, {{responseType}}._DESERIALIZER ); -} \ No newline at end of file + + {{>ObjectShape/HashCode}} + + {{>ObjectShape/Equals}} +} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache index 236daf9abb..c59a635d39 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache @@ -111,4 +111,9 @@ } public static final {{TYPES.Client.Json.JsonpDeserializer}}<{{className}}> _DESERIALIZER = {{TYPES.Client.Json.JsonpDeserializer}}.lazy({{className}}::build{{className}}Deserializer); + + {{>ObjectShape/TaggedUnionHashCode}} + + {{>ObjectShape/TaggedUnionEquals}} + } From a64048501ffd01eddae3df534f987e66cda75263 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Wed, 2 Oct 2024 03:22:24 +1300 Subject: [PATCH 2/2] Re-run codegen (#1216) * Re-run codegen Signed-off-by: Thomas Farr * Improve null handling Signed-off-by: Thomas Farr --------- Signed-off-by: Thomas Farr (cherry picked from commit 897cc9bb34d05dd852b1a0b2fcd5621d9bd81628) --- .../client/opensearch/_types/ErrorCause.java | 13 ++++++-- .../opensearch/_types/ShardFailure.java | 9 +++-- .../opensearch/_types/ShardStatistics.java | 17 +++++++--- .../opensearch/_types/WriteResponseBase.java | 29 ++++++++++------ .../client/opensearch/ml/Action.java | 2 +- .../client/opensearch/ml/ClientConfig.java | 26 +++++++-------- .../opensearch/ml/CreateConnectorRequest.java | 29 +++++++++++----- .../ml/CreateConnectorResponse.java | 2 +- .../client/opensearch/ml/Credential.java | 5 ++- .../opensearch/ml/DeleteAgentRequest.java | 8 +++-- .../opensearch/ml/DeleteAgentResponse.java | 2 +- .../opensearch/ml/DeleteConnectorRequest.java | 8 +++-- .../ml/DeleteConnectorResponse.java | 2 +- .../ml/DeleteModelGroupRequest.java | 8 +++-- .../ml/DeleteModelGroupResponse.java | 2 +- .../opensearch/ml/DeleteModelRequest.java | 8 +++-- .../opensearch/ml/DeleteModelResponse.java | 2 +- .../opensearch/ml/DeleteTaskRequest.java | 8 +++-- .../opensearch/ml/DeleteTaskResponse.java | 2 +- .../opensearch/ml/DeployModelRequest.java | 8 +++-- .../opensearch/ml/DeployModelResponse.java | 11 ++++--- .../opensearch/ml/GetModelGroupRequest.java | 8 +++-- .../opensearch/ml/GetModelGroupResponse.java | 25 +++++++++----- .../client/opensearch/ml/GetTaskRequest.java | 8 +++-- .../client/opensearch/ml/GetTaskResponse.java | 21 +++++++----- .../client/opensearch/ml/Headers.java | 5 ++- .../opensearch/client/opensearch/ml/LLM.java | 5 ++- .../client/opensearch/ml/Memory.java | 2 +- .../opensearch/ml/RegisterAgentsRequest.java | 15 +++++++-- .../opensearch/ml/RegisterAgentsResponse.java | 2 +- .../ml/RegisterModelGroupRequest.java | 13 +++++--- .../ml/RegisterModelGroupResponse.java | 10 ++++-- .../opensearch/ml/RegisterModelRequest.java | 15 ++++++--- .../opensearch/ml/RegisterModelResponse.java | 10 ++++-- .../client/opensearch/ml/ToolItems.java | 7 +++- .../opensearch/ml/UndeployModelNode.java | 5 ++- .../opensearch/ml/UndeployModelRequest.java | 8 +++-- .../opensearch/ml/UndeployModelResponse.java | 5 ++- .../client/codegen/model/Field.java | 8 ----- .../opensearch/client/codegen/model/Type.java | 33 ++++++------------- .../client/codegen/model/Types.java | 1 + .../templates/ObjectShape/Equals.mustache | 17 ++++++---- .../ObjectShape/FieldNullability.mustache | 13 ++++++++ .../templates/ObjectShape/Fields.mustache | 6 +--- .../templates/ObjectShape/Getters.mustache | 6 +--- .../templates/ObjectShape/HashCode.mustache | 23 ++++++------- .../ObjectShape/TaggedUnionEquals.mustache | 6 ---- .../ObjectShape/TaggedUnionHashCode.mustache | 6 ---- .../templates/TaggedUnionShape.mustache | 5 ++- .../TaggedUnionShape/Equals.mustache | 6 ++++ .../TaggedUnionShape/HashCode.mustache | 6 ++++ .../templates/Type/deserializer.mustache | 20 ++++++++--- .../templates/Type/directSerializer.mustache | 17 ++++++---- .../templates/Type/queryParamify.mustache | 8 ++--- 54 files changed, 338 insertions(+), 208 deletions(-) create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldNullability.mustache delete mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionEquals.mustache delete mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionHashCode.mustache create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/Equals.mustache create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/HashCode.mustache diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java index de1cad3599..36a0c74b71 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java @@ -43,6 +43,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.JsonData; import org.opensearch.client.json.JsonpDeserializable; @@ -67,15 +68,19 @@ public class ErrorCause implements PlainJsonSerializable { @Nullable private final String reason; + @Nonnull private final List rootCause; @Nullable private final String stackTrace; + @Nonnull private final List suppressed; + @Nonnull private final String type; + @Nonnull private final Map metadata; // --------------------------------------------------------------------------------------------- @@ -116,6 +121,7 @@ public final String reason() { /** * API name: {@code root_cause} */ + @Nonnull public final List rootCause() { return this.rootCause; } @@ -134,6 +140,7 @@ public final String stackTrace() { /** * API name: {@code suppressed} */ + @Nonnull public final List suppressed() { return this.suppressed; } @@ -144,6 +151,7 @@ public final List suppressed() { * API name: {@code type} *

*/ + @Nonnull public final String type() { return this.type; } @@ -151,6 +159,7 @@ public final String type() { /** * Additional details about the error. */ + @Nonnull public final Map metadata() { return this.metadata; } @@ -420,14 +429,14 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; ErrorCause other = (ErrorCause) o; return Objects.equals(this.causedBy, other.causedBy) && Objects.equals(this.reason, other.reason) && Objects.equals(this.rootCause, other.rootCause) && Objects.equals(this.stackTrace, other.stackTrace) && Objects.equals(this.suppressed, other.suppressed) - && Objects.equals(this.type, other.type) + && this.type.equals(other.type) && Objects.equals(this.metadata, other.metadata); } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardFailure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardFailure.java index 702c37b8a6..36812d4783 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardFailure.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardFailure.java @@ -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; @@ -63,6 +64,7 @@ public class ShardFailure implements PlainJsonSerializable { @Nullable private final String node; + @Nonnull private final ErrorCause reason; private final int shard; @@ -103,6 +105,7 @@ public final String node() { /** * Required - API name: {@code reason} */ + @Nonnull public final ErrorCause reason() { return this.reason; } @@ -259,12 +262,12 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; ShardFailure other = (ShardFailure) o; return Objects.equals(this.index, other.index) && Objects.equals(this.node, other.node) - && Objects.equals(this.reason, other.reason) - && this.shard() == other.shard() + && this.reason.equals(other.reason) + && this.shard == other.shard && Objects.equals(this.status, other.status); } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardStatistics.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardStatistics.java index 447e8404c7..53d36332e7 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardStatistics.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardStatistics.java @@ -41,6 +41,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; @@ -58,15 +59,19 @@ @Generated("org.opensearch.client.codegen.CodeGenerator") public class ShardStatistics implements PlainJsonSerializable { + @Nonnull private final Number failed; + @Nonnull private final List failures; @Nullable private final Number skipped; + @Nonnull private final Number successful; + @Nonnull private final Number total; // --------------------------------------------------------------------------------------------- @@ -86,6 +91,7 @@ public static ShardStatistics of(Function failures() { return this.failures; } @@ -108,6 +115,7 @@ public final Number skipped() { /** * Required - API name: {@code successful} */ + @Nonnull public final Number successful() { return this.successful; } @@ -115,6 +123,7 @@ public final Number successful() { /** * Required - API name: {@code total} */ + @Nonnull public final Number total() { return this.total; } @@ -277,12 +286,12 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; ShardStatistics other = (ShardStatistics) o; - return Objects.equals(this.failed, other.failed) + return this.failed.equals(other.failed) && Objects.equals(this.failures, other.failures) && Objects.equals(this.skipped, other.skipped) - && Objects.equals(this.successful, other.successful) - && Objects.equals(this.total, other.total); + && this.successful.equals(other.successful) + && this.total.equals(other.total); } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/WriteResponseBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/WriteResponseBase.java index ce3f4c841d..851f7c50dd 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/WriteResponseBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/WriteResponseBase.java @@ -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.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -57,16 +58,20 @@ public abstract class WriteResponseBase implements PlainJsonSerializable { @Nullable private final Boolean forcedRefresh; + @Nonnull private final String id; + @Nonnull private final String index; private final long primaryTerm; + @Nonnull private final Result result; private final long seqNo; + @Nonnull private final ShardStatistics shards; private final long version; @@ -95,6 +100,7 @@ public final Boolean forcedRefresh() { /** * Required - API name: {@code _id} */ + @Nonnull public final String id() { return this.id; } @@ -102,6 +108,7 @@ public final String id() { /** * Required - API name: {@code _index} */ + @Nonnull public final String index() { return this.index; } @@ -116,6 +123,7 @@ public final long primaryTerm() { /** * Required - API name: {@code result} */ + @Nonnull public final Result result() { return this.result; } @@ -130,6 +138,7 @@ public final long seqNo() { /** * Required - API name: {@code _shards} */ + @Nonnull public final ShardStatistics shards() { return this.shards; } @@ -281,7 +290,7 @@ protected static > void setupWriteRes public int hashCode() { int result = 17; - result = 31 * result + Boolean.hashCode(this.forcedRefresh); + result = 31 * result + Objects.hashCode(this.forcedRefresh); result = 31 * result + this.id.hashCode(); result = 31 * result + this.index.hashCode(); result = 31 * result + Long.hashCode(this.primaryTerm); @@ -294,15 +303,15 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; WriteResponseBase other = (WriteResponseBase) o; - return this.forcedRefresh() == other.forcedRefresh() - && Objects.equals(this.id, other.id) - && Objects.equals(this.index, other.index) - && this.primaryTerm() == other.primaryTerm() - && Objects.equals(this.result, other.result) - && this.seqNo() == other.seqNo() - && Objects.equals(this.shards, other.shards) - && this.version() == other.version(); + return Objects.equals(this.forcedRefresh, other.forcedRefresh) + && this.id.equals(other.id) + && this.index.equals(other.index) + && this.primaryTerm == other.primaryTerm + && this.result.equals(other.result) + && this.seqNo == other.seqNo + && this.shards.equals(other.shards) + && this.version == other.version; } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Action.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Action.java index 68e20bc646..38e6fa54af 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Action.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Action.java @@ -302,7 +302,7 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; Action other = (Action) o; return Objects.equals(this.actionType, other.actionType) && Objects.equals(this.headers, other.headers) diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/ClientConfig.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/ClientConfig.java index 0a3fa1a853..bd03b5ec22 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/ClientConfig.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/ClientConfig.java @@ -283,26 +283,26 @@ protected static void setupClientConfigDeserializer(ObjectDeserializer actions; @Nullable private final ClientConfig clientConfig; + @Nonnull private final Credential credential; + @Nonnull private final String description; + @Nonnull private final String name; + @Nonnull private final Map parameters; + @Nonnull private final String protocol; private final int version; @@ -80,6 +87,7 @@ public static CreateConnectorRequest of(Function actions() { return this.actions; } @@ -95,6 +103,7 @@ public final ClientConfig clientConfig() { /** * Required - API name: {@code credential} */ + @Nonnull public final Credential credential() { return this.credential; } @@ -102,6 +111,7 @@ public final Credential credential() { /** * Required - API name: {@code description} */ + @Nonnull public final String description() { return this.description; } @@ -109,6 +119,7 @@ public final String description() { /** * Required - API name: {@code name} */ + @Nonnull public final String name() { return this.name; } @@ -116,6 +127,7 @@ public final String name() { /** * Required - API name: {@code parameters} */ + @Nonnull public final Map parameters() { return this.parameters; } @@ -123,6 +135,7 @@ public final Map parameters() { /** * Required - API name: {@code protocol} */ + @Nonnull public final String protocol() { return this.protocol; } @@ -382,15 +395,15 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; CreateConnectorRequest other = (CreateConnectorRequest) o; - return Objects.equals(this.actions, other.actions) + return this.actions.equals(other.actions) && Objects.equals(this.clientConfig, other.clientConfig) - && Objects.equals(this.credential, other.credential) - && Objects.equals(this.description, other.description) - && Objects.equals(this.name, other.name) - && Objects.equals(this.parameters, other.parameters) - && Objects.equals(this.protocol, other.protocol) - && this.version() == other.version(); + && this.credential.equals(other.credential) + && this.description.equals(other.description) + && this.name.equals(other.name) + && this.parameters.equals(other.parameters) + && this.protocol.equals(other.protocol) + && this.version == other.version; } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/CreateConnectorResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/CreateConnectorResponse.java index 309c8e4c95..bed71edbbc 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/CreateConnectorResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/CreateConnectorResponse.java @@ -121,7 +121,7 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; CreateConnectorResponse other = (CreateConnectorResponse) o; return Objects.equals(this.connectorId, other.connectorId); } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Credential.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Credential.java index 1e465e9f59..ef7dfb84ad 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Credential.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Credential.java @@ -18,6 +18,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.JsonData; import org.opensearch.client.json.JsonpDeserializable; @@ -45,6 +46,7 @@ public class Credential implements PlainJsonSerializable { @Nullable private final String sessionToken; + @Nonnull private final Map metadata; // --------------------------------------------------------------------------------------------- @@ -86,6 +88,7 @@ public final String sessionToken() { /** */ + @Nonnull public final Map metadata() { return this.metadata; } @@ -227,7 +230,7 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; Credential other = (Credential) o; return Objects.equals(this.accessKey, other.accessKey) && Objects.equals(this.secretKey, other.secretKey) diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteAgentRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteAgentRequest.java index 95483fb1fa..da99ed04fa 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteAgentRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteAgentRequest.java @@ -12,9 +12,9 @@ package org.opensearch.client.opensearch.ml; -import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; +import javax.annotation.Nonnull; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.RequestBase; import org.opensearch.client.transport.Endpoint; @@ -31,6 +31,7 @@ @Generated("org.opensearch.client.codegen.CodeGenerator") public class DeleteAgentRequest extends RequestBase { + @Nonnull private final String agentId; // --------------------------------------------------------------------------------------------- @@ -46,6 +47,7 @@ public static DeleteAgentRequest of(Function */ + @Nonnull public final String access() { return this.access; } @@ -86,6 +91,7 @@ public final Long createdTime() { * API name: {@code description} *

*/ + @Nonnull public final String description() { return this.description; } @@ -114,6 +120,7 @@ public final int latestVersion() { * API name: {@code name} *

*/ + @Nonnull public final String name() { return this.name; } @@ -261,9 +268,9 @@ protected static void setupGetModelGroupResponseDeserializer(ObjectDeserializer< public int hashCode() { int result = 17; result = 31 * result + this.access.hashCode(); - result = 31 * result + Long.hashCode(this.createdTime); + result = 31 * result + Objects.hashCode(this.createdTime); result = 31 * result + this.description.hashCode(); - result = 31 * result + Long.hashCode(this.lastUpdatedTime); + result = 31 * result + Objects.hashCode(this.lastUpdatedTime); result = 31 * result + Integer.hashCode(this.latestVersion); result = 31 * result + this.name.hashCode(); return result; @@ -271,13 +278,13 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; GetModelGroupResponse other = (GetModelGroupResponse) o; - return Objects.equals(this.access, other.access) - && this.createdTime() == other.createdTime() - && Objects.equals(this.description, other.description) - && this.lastUpdatedTime() == other.lastUpdatedTime() - && this.latestVersion() == other.latestVersion() - && Objects.equals(this.name, other.name); + return this.access.equals(other.access) + && Objects.equals(this.createdTime, other.createdTime) + && this.description.equals(other.description) + && Objects.equals(this.lastUpdatedTime, other.lastUpdatedTime) + && this.latestVersion == other.latestVersion + && this.name.equals(other.name); } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/GetTaskRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/GetTaskRequest.java index 76dbbc8352..664c9b3d31 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/GetTaskRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/GetTaskRequest.java @@ -12,9 +12,9 @@ package org.opensearch.client.opensearch.ml; -import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; +import javax.annotation.Nonnull; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.RequestBase; import org.opensearch.client.transport.Endpoint; @@ -31,6 +31,7 @@ @Generated("org.opensearch.client.codegen.CodeGenerator") public class GetTaskRequest extends RequestBase { + @Nonnull private final String taskId; // --------------------------------------------------------------------------------------------- @@ -46,6 +47,7 @@ public static GetTaskRequest of(Function> workerNode; // --------------------------------------------------------------------------------------------- @@ -132,6 +135,7 @@ public final String modelId() { /** * Required - API name: {@code state} */ + @Nonnull public final String state() { return this.state; } @@ -158,6 +162,7 @@ public final String taskType() { /** * API name: {@code worker_node} */ + @Nonnull public final List> workerNode() { return this.workerNode; } @@ -396,11 +401,11 @@ protected static void setupGetTaskResponseDeserializer(ObjectDeserializer metadata; // --------------------------------------------------------------------------------------------- @@ -62,6 +64,7 @@ public final String contentType() { /** */ + @Nonnull public final Map metadata() { return this.metadata; } @@ -169,7 +172,7 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; Headers other = (Headers) o; return Objects.equals(this.contentType, other.contentType) && Objects.equals(this.metadata, other.metadata); } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/LLM.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/LLM.java index 2455229411..2f0613294a 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/LLM.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/LLM.java @@ -17,6 +17,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.JsonData; import org.opensearch.client.json.JsonpDeserializable; @@ -38,6 +39,7 @@ public class LLM implements PlainJsonSerializable { @Nullable private final String modelId; + @Nonnull private final Map parameters; // --------------------------------------------------------------------------------------------- @@ -62,6 +64,7 @@ public final String modelId() { /** * API name: {@code parameters} */ + @Nonnull public final Map parameters() { return this.parameters; } @@ -169,7 +172,7 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; LLM other = (LLM) o; return Objects.equals(this.modelId, other.modelId) && Objects.equals(this.parameters, other.parameters); } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Memory.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Memory.java index 3ae6dcaf1e..0660178e13 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Memory.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Memory.java @@ -121,7 +121,7 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; Memory other = (Memory) o; return Objects.equals(this.type, other.type); } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsRequest.java index 1924edac77..2c2e560a6d 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsRequest.java @@ -18,6 +18,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.JsonData; import org.opensearch.client.json.JsonpDeserializable; @@ -55,12 +56,16 @@ public class RegisterAgentsRequest extends RequestBase implements PlainJsonSeria @Nullable private final Memory memory; + @Nonnull private final String name; + @Nonnull private final Map parameters; + @Nonnull private final List tools; + @Nonnull private final String type; // --------------------------------------------------------------------------------------------- @@ -115,6 +120,7 @@ public final Memory memory() { /** * Required - API name: {@code name} */ + @Nonnull public final String name() { return this.name; } @@ -122,6 +128,7 @@ public final String name() { /** * API name: {@code parameters} */ + @Nonnull public final Map parameters() { return this.parameters; } @@ -129,6 +136,7 @@ public final Map parameters() { /** * API name: {@code tools} */ + @Nonnull public final List tools() { return this.tools; } @@ -136,6 +144,7 @@ public final List tools() { /** * Required - API name: {@code type} */ + @Nonnull public final String type() { return this.type; } @@ -403,15 +412,15 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; RegisterAgentsRequest other = (RegisterAgentsRequest) o; return Objects.equals(this.appType, other.appType) && Objects.equals(this.description, other.description) && Objects.equals(this.llm, other.llm) && Objects.equals(this.memory, other.memory) - && Objects.equals(this.name, other.name) + && this.name.equals(other.name) && Objects.equals(this.parameters, other.parameters) && Objects.equals(this.tools, other.tools) - && Objects.equals(this.type, other.type); + && this.type.equals(other.type); } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsResponse.java index 199ae5fde6..b15475a2aa 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsResponse.java @@ -121,7 +121,7 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; RegisterAgentsResponse other = (RegisterAgentsResponse) o; return Objects.equals(this.agentId, other.agentId); } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java index b9f1b069fd..e7bc41bb13 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java @@ -17,6 +17,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; @@ -47,11 +48,13 @@ public class RegisterModelGroupRequest extends RequestBase implements PlainJsonS @Nullable private final Boolean addAllBackendRoles; + @Nonnull private final List backendRoles; @Nullable private final String description; + @Nonnull private final String name; // --------------------------------------------------------------------------------------------- @@ -96,6 +99,7 @@ public final Boolean addAllBackendRoles() { * API name: {@code backend_roles} *

*/ + @Nonnull public final List backendRoles() { return this.backendRoles; } @@ -117,6 +121,7 @@ public final String description() { * API name: {@code name} *

*/ + @Nonnull public final String name() { return this.name; } @@ -299,7 +304,7 @@ protected static void setupRegisterModelGroupRequestDeserializer(ObjectDeseriali public int hashCode() { int result = 17; result = 31 * result + Objects.hashCode(this.accessMode); - result = 31 * result + Boolean.hashCode(this.addAllBackendRoles); + result = 31 * result + Objects.hashCode(this.addAllBackendRoles); result = 31 * result + Objects.hashCode(this.backendRoles); result = 31 * result + Objects.hashCode(this.description); result = 31 * result + this.name.hashCode(); @@ -308,12 +313,12 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; RegisterModelGroupRequest other = (RegisterModelGroupRequest) o; return Objects.equals(this.accessMode, other.accessMode) - && this.addAllBackendRoles() == other.addAllBackendRoles() + && Objects.equals(this.addAllBackendRoles, other.addAllBackendRoles) && Objects.equals(this.backendRoles, other.backendRoles) && Objects.equals(this.description, other.description) - && Objects.equals(this.name, other.name); + && this.name.equals(other.name); } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java index 6ee1aab4cf..ac99154507 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java @@ -13,9 +13,9 @@ package org.opensearch.client.opensearch.ml; import jakarta.json.stream.JsonGenerator; -import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; +import javax.annotation.Nonnull; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -32,8 +32,10 @@ @Generated("org.opensearch.client.codegen.CodeGenerator") public class RegisterModelGroupResponse implements PlainJsonSerializable { + @Nonnull private final String modelGroupId; + @Nonnull private final String status; // --------------------------------------------------------------------------------------------- @@ -55,6 +57,7 @@ public static RegisterModelGroupResponse of( * API name: {@code model_group_id} *

*/ + @Nonnull public final String modelGroupId() { return this.modelGroupId; } @@ -65,6 +68,7 @@ public final String modelGroupId() { * API name: {@code status} *

*/ + @Nonnull public final String status() { return this.status; } @@ -154,8 +158,8 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; RegisterModelGroupResponse other = (RegisterModelGroupResponse) o; - return Objects.equals(this.modelGroupId, other.modelGroupId) && Objects.equals(this.status, other.status); + return this.modelGroupId.equals(other.modelGroupId) && this.status.equals(other.status); } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java index 9536644078..5261601622 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java @@ -16,6 +16,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; @@ -43,13 +44,16 @@ public class RegisterModelRequest extends RequestBase implements PlainJsonSerial @Nullable private final String description; + @Nonnull private final String modelFormat; @Nullable private final String modelGroupId; + @Nonnull private final String name; + @Nonnull private final String version; // --------------------------------------------------------------------------------------------- @@ -83,6 +87,7 @@ public final String description() { * API name: {@code model_format} *

*/ + @Nonnull public final String modelFormat() { return this.modelFormat; } @@ -104,6 +109,7 @@ public final String modelGroupId() { * API name: {@code name} *

*/ + @Nonnull public final String name() { return this.name; } @@ -114,6 +120,7 @@ public final String name() { * API name: {@code version} *

*/ + @Nonnull public final String version() { return this.version; } @@ -276,12 +283,12 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; RegisterModelRequest other = (RegisterModelRequest) o; return Objects.equals(this.description, other.description) - && Objects.equals(this.modelFormat, other.modelFormat) + && this.modelFormat.equals(other.modelFormat) && Objects.equals(this.modelGroupId, other.modelGroupId) - && Objects.equals(this.name, other.name) - && Objects.equals(this.version, other.version); + && this.name.equals(other.name) + && this.version.equals(other.version); } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelResponse.java index 4bcac19b3b..d565876256 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelResponse.java @@ -13,9 +13,9 @@ package org.opensearch.client.opensearch.ml; import jakarta.json.stream.JsonGenerator; -import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; +import javax.annotation.Nonnull; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -32,8 +32,10 @@ @Generated("org.opensearch.client.codegen.CodeGenerator") public class RegisterModelResponse implements PlainJsonSerializable { + @Nonnull private final String status; + @Nonnull private final String taskId; // --------------------------------------------------------------------------------------------- @@ -50,6 +52,7 @@ public static RegisterModelResponse of(Function parameters; @Nullable private final String type; + @Nonnull private final Map metadata; // --------------------------------------------------------------------------------------------- @@ -70,6 +73,7 @@ public final String name() { /** * API name: {@code parameters} */ + @Nonnull public final Map parameters() { return this.parameters; } @@ -84,6 +88,7 @@ public final String type() { /** */ + @Nonnull public final Map metadata() { return this.metadata; } @@ -246,7 +251,7 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; ToolItems other = (ToolItems) o; return Objects.equals(this.name, other.name) && Objects.equals(this.parameters, other.parameters) diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelNode.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelNode.java index 0a7a3d58c7..9b9afcbc98 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelNode.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelNode.java @@ -17,6 +17,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.JsonData; import org.opensearch.client.json.JsonpDeserializable; @@ -35,6 +36,7 @@ @Generated("org.opensearch.client.codegen.CodeGenerator") public class UndeployModelNode implements PlainJsonSerializable { + @Nonnull private final Map stats; // --------------------------------------------------------------------------------------------- @@ -50,6 +52,7 @@ public static UndeployModelNode of(Function stats() { return this.stats; } @@ -143,7 +146,7 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; UndeployModelNode other = (UndeployModelNode) o; return Objects.equals(this.stats, other.stats); } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelRequest.java index 0b9f760371..5c5a4a4eed 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelRequest.java @@ -12,9 +12,9 @@ package org.opensearch.client.opensearch.ml; -import java.util.Objects; import java.util.function.Function; import javax.annotation.Generated; +import javax.annotation.Nonnull; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.RequestBase; import org.opensearch.client.transport.Endpoint; @@ -31,6 +31,7 @@ @Generated("org.opensearch.client.codegen.CodeGenerator") public class UndeployModelRequest extends RequestBase { + @Nonnull private final String modelId; // --------------------------------------------------------------------------------------------- @@ -46,6 +47,7 @@ public static UndeployModelRequest of(Function nodes; // --------------------------------------------------------------------------------------------- @@ -49,6 +51,7 @@ public static UndeployModelResponse of(Function nodes() { return this.nodes; } @@ -150,7 +153,7 @@ public int hashCode() { public boolean equals(Object o) { if (this == o) return true; - if (this.getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; UndeployModelResponse other = (UndeployModelResponse) o; return Objects.equals(this.nodes, other.nodes); } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java index 03025401cb..e4d1734572 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java @@ -84,12 +84,4 @@ public String getDescription() { public Deprecation getDeprecation() { return deprecation; } - - public boolean isUnboxedPrimitive() { - return type.isUnboxedPrimitive(); - } - - public Type getBoxedType() { - return type.getBoxed(); - } } 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 d9123a7eaa..f46c3f0306 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 @@ -23,25 +23,16 @@ import org.opensearch.client.codegen.utils.Strings; public class Type { - private static final Set PRIMITIVES = Set.of( - "String", - "boolean", + private static final Set PRIMITIVES = Set.of("boolean", "char", "byte", "short", "int", "long", "float", "double"); + private static final Set BOXED_PRIMITIVES = Set.of( "Boolean", - "char", "Character", - "byte", "Byte", - "short", "Short", - "int", "Integer", - "long", "Long", - "float", "Float", - "double", - "Double", - "Number" + "Double" ); @Nonnull @@ -157,16 +148,12 @@ public boolean isPrimitive() { return PRIMITIVES.contains(name); } - public boolean isUnboxedPrimitive() { - return isPrimitive() - && !name.equals("String") - && !name.equals("Boolean") - && !name.equals("Character") - && !name.equals("Integer") - && !name.equals("Long") - && !name.equals("Float") - && !name.equals("Double") - && !name.equals("Number"); + public boolean isBoxedPrimitive() { + return BOXED_PRIMITIVES.contains(name); + } + + public boolean isPotentiallyBoxedPrimitive() { + return isPrimitive() || isBoxedPrimitive(); } public boolean isNumber() { @@ -182,7 +169,7 @@ public boolean isTime() { } public boolean isBuiltIn() { - return isListOrMap() || isPrimitive() || "JsonData".equals(name); + return isPrimitive() || (packageName != null && packageName.startsWith("java.")) || "JsonData".equals(name); } public boolean hasBuilder() { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java index d5f4e9a750..aff4712672 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java @@ -123,6 +123,7 @@ public static final class Javax { public static final class Annotation { public static final String PACKAGE = Javax.PACKAGE + ".annotation"; public static final Type Generated = Type.builder().withPackage(PACKAGE).withName("Generated").build(); + public static final Type Nonnull = Type.builder().withPackage(PACKAGE).withName("Nonnull").build(); public static final Type Nullable = Type.builder().withPackage(PACKAGE).withName("Nullable").build(); } } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Equals.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Equals.mustache index 6e45e22d72..1670834380 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Equals.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Equals.mustache @@ -5,7 +5,7 @@ } {{/extendsOtherShape}} if(this == o) return true; - if(this.getClass() != o.getClass()) return false; + if(o == null || this.getClass() != o.getClass()) return false; {{^hasFields}} return true; {{/hasFields}} @@ -13,12 +13,17 @@ {{className}} other = ({{className}})o; return {{#fields}} - {{#isUnboxedPrimitive}} - this.{{name}}() == other.{{name}}() - {{/isUnboxedPrimitive}} - {{^isUnboxedPrimitive}} + {{#required}} + {{#type.isPrimitive}} + this.{{name}} == other.{{name}} + {{/type.isPrimitive}} + {{^type.isPrimitive}} + this.{{name}}.equals(other.{{name}}) + {{/type.isPrimitive}} + {{/required}} + {{^required}} {{TYPES.Java.Util.Objects}}.equals(this.{{name}}, other.{{name}}) - {{/isUnboxedPrimitive}} + {{/required}} {{^-last}} && {{/-last}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldNullability.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldNullability.mustache new file mode 100644 index 0000000000..f9739563bb --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldNullability.mustache @@ -0,0 +1,13 @@ +{{#type.isListOrMap}} + @{{TYPES.Javax.Annotation.Nonnull}} +{{/type.isListOrMap}} +{{^type.isListOrMap}} + {{#required}} + {{^type.isPrimitive}} + @{{TYPES.Javax.Annotation.Nonnull}} + {{/type.isPrimitive}} + {{/required}} + {{^required}} + @{{TYPES.Javax.Annotation.Nullable}} + {{/required}} +{{/type.isListOrMap}} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Fields.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Fields.mustache index bd320a391b..7e3bea7471 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Fields.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Fields.mustache @@ -3,10 +3,6 @@ {{/-first}} {{#deprecation}}@Deprecated{{/deprecation}} -{{^required}} -{{^type.isListOrMap}} - @{{TYPES.Javax.Annotation.Nullable}} -{{/type.isListOrMap}} -{{/required}} + {{>ObjectShape/FieldNullability}} private final {{type}} {{name}}; {{/fields}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Getters.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Getters.mustache index 61fea36e57..b9742a7b13 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Getters.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Getters.mustache @@ -2,11 +2,7 @@ {{>ObjectShape/FieldDoc/Basic}} {{#deprecation}}@Deprecated{{/deprecation}} - {{^required}} - {{^type.isListOrMap}} - @{{TYPES.Javax.Annotation.Nullable}} - {{/type.isListOrMap}} - {{/required}} + {{>ObjectShape/FieldNullability}} public final {{type}} {{name}}() { return this.{{name}}; } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/HashCode.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/HashCode.mustache index 5418321cc6..d14479eb81 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/HashCode.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/HashCode.mustache @@ -6,17 +6,18 @@ int result = 17; {{/extendsOtherShape}} {{#fields}} - {{#isUnboxedPrimitive}} - result = 31 * result + {{getBoxedType}}.hashCode(this.{{name}}); - {{/isUnboxedPrimitive}} - {{^isUnboxedPrimitive}} - {{#isRequired}} - result = 31 * result + this.{{name}}.hashCode(); - {{/isRequired}} - {{^isRequired}} - result = 31 * result + {{TYPES.Java.Util.Objects}}.hashCode(this.{{name}}); - {{/isRequired}} - {{/isUnboxedPrimitive}} + result = 31 * result + + {{#required}} + {{#type.isPrimitive}} + {{type.boxed}}.hashCode(this.{{name}}); + {{/type.isPrimitive}} + {{^type.isPrimitive}} + this.{{name}}.hashCode(); + {{/type.isPrimitive}} + {{/required}} + {{^required}} + {{TYPES.Java.Util.Objects}}.hashCode(this.{{name}}); + {{/required}} {{/fields}} return result; } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionEquals.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionEquals.mustache deleted file mode 100644 index 7a368dc538..0000000000 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionEquals.mustache +++ /dev/null @@ -1,6 +0,0 @@ - public boolean equals(Object o) { - if(this == o) return true; - if(this.getClass() != o.getClass()) return false; - {{className}} other = ({{className}})o; - return this._kind().equals(other._kind()) && this._get().equals(other._get()); - } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionHashCode.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionHashCode.mustache deleted file mode 100644 index 8cd7137529..0000000000 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/TaggedUnionHashCode.mustache +++ /dev/null @@ -1,6 +0,0 @@ - public int hashCode() { - int result = 17; - result = 31 * result + _kind.hashCode(); - result = 31 * result + _value.hashCode(); - return result; - } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache index c59a635d39..8a584d6812 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache @@ -112,8 +112,7 @@ public static final {{TYPES.Client.Json.JsonpDeserializer}}<{{className}}> _DESERIALIZER = {{TYPES.Client.Json.JsonpDeserializer}}.lazy({{className}}::build{{className}}Deserializer); - {{>ObjectShape/TaggedUnionHashCode}} - - {{>ObjectShape/TaggedUnionEquals}} + {{>TaggedUnionShape/HashCode}} + {{>TaggedUnionShape/Equals}} } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/Equals.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/Equals.mustache new file mode 100644 index 0000000000..ece94de59b --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/Equals.mustache @@ -0,0 +1,6 @@ + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || this.getClass() != o.getClass()) return false; + {{className}} other = ({{className}})o; + return {{TYPES.Java.Util.Objects}}.equals(this._kind, other._kind) && {{TYPES.Java.Util.Objects}}.equals(this._value, other._value); + } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/HashCode.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/HashCode.mustache new file mode 100644 index 0000000000..eb7a1d39a1 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/HashCode.mustache @@ -0,0 +1,6 @@ + public int hashCode() { + int result = 17; + result = 31 * result + {{TYPES.Java.Util.Objects}}.hashCode(this._kind); + result = 31 * result + {{TYPES.Java.Util.Objects}}.hashCode(this._value); + return result; + } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache index 61fb38b72b..25d0754571 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache @@ -1,7 +1,7 @@ -{{#isPrimitive}} +{{#isPotentiallyBoxedPrimitive}} {{TYPES.Client.Json.JsonpDeserializer}}.{{#toLower}}{{boxed.name}}{{/toLower}}Deserializer() -{{/isPrimitive}} -{{^isPrimitive}} +{{/isPotentiallyBoxedPrimitive}} +{{^isPotentiallyBoxedPrimitive}} {{#isList}} {{TYPES.Client.Json.JsonpDeserializer}}.arrayDeserializer({{#listValueType}}{{>Type/deserializer}}{{/listValueType}}) {{/isList}} @@ -9,6 +9,16 @@ {{TYPES.Client.Json.JsonpDeserializer}}.stringMapDeserializer({{#mapValueType}}{{>Type/deserializer}}{{/mapValueType}}) {{/isMap}} {{^isListOrMap}} - {{name}}._DESERIALIZER + {{#isNumber}} + {{TYPES.Client.Json.JsonpDeserializer}}.numberDeserializer() + {{/isNumber}} + {{^isNumber}} + {{#isString}} + {{TYPES.Client.Json.JsonpDeserializer}}.stringDeserializer() + {{/isString}} + {{^isString}} + {{name}}._DESERIALIZER + {{/isString}} + {{/isNumber}} {{/isListOrMap}} -{{/isPrimitive}} \ No newline at end of file +{{/isPotentiallyBoxedPrimitive}} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache index f8c2fb10cd..34f4345fca 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache @@ -10,15 +10,20 @@ } {{/type.isList}} {{^type.isListOrMap}} - {{#type.isPrimitive}} + {{#type.isPotentiallyBoxedPrimitive}} + generator.write({{value}}); + {{/type.isPotentiallyBoxedPrimitive}} + {{^type.isPotentiallyBoxedPrimitive}} {{#type.isNumber}} generator.write({{value}}.doubleValue()); {{/type.isNumber}} {{^type.isNumber}} - generator.write({{value}}); + {{#type.isString}} + generator.write({{value}}); + {{/type.isString}} + {{^type.isString}} + {{value}}.serialize(generator, mapper); + {{/type.isString}} {{/type.isNumber}} - {{/type.isPrimitive}} - {{^type.isPrimitive}} - {{value}}.serialize(generator, mapper); - {{/type.isPrimitive}} + {{/type.isPotentiallyBoxedPrimitive}} {{/type.isListOrMap}} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/queryParamify.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/queryParamify.mustache index 1abc099c55..ebdacdc7ae 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/queryParamify.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/queryParamify.mustache @@ -6,10 +6,10 @@ {{value}}.jsonValue() {{/type.isEnum}} {{^type.isEnum}} - {{#type.isPrimitive}} + {{#type.isPotentiallyBoxedPrimitive}} String.valueOf({{value}}) - {{/type.isPrimitive}} - {{^type.isPrimitive}} + {{/type.isPotentiallyBoxedPrimitive}} + {{^type.isPotentiallyBoxedPrimitive}} {{#type.isList}} {{#type.listValueType.isString}} String.join(",", {{value}}) @@ -24,6 +24,6 @@ {{^type.isList}} {{value}}._toJsonString() {{/type.isList}} - {{/type.isPrimitive}} + {{/type.isPotentiallyBoxedPrimitive}} {{/type.isEnum}} {{/type.isString}}