From 46df77f9edf92256f7c367f5a8475b844b9496af Mon Sep 17 00:00:00 2001 From: Otavio Santana Date: Wed, 29 Nov 2023 05:31:35 +0000 Subject: [PATCH] docs: create searchByid documentation Signed-off-by: Otavio Santana --- .../java/expert/os/harperdb/SearchById.java | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/expert/os/harperdb/SearchById.java b/core/src/main/java/expert/os/harperdb/SearchById.java index 577240f..46b0539 100644 --- a/core/src/main/java/expert/os/harperdb/SearchById.java +++ b/core/src/main/java/expert/os/harperdb/SearchById.java @@ -2,9 +2,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; import java.util.Set; -final class SearchById extends Operation{ +/** + * Represents the "search by ID" operation in HarperDB. + * This operation is used to retrieve records from a specific table in a given database based on their IDs. + */ +final class SearchById extends Operation { @JsonProperty @@ -19,6 +24,14 @@ final class SearchById extends Operation{ @JsonProperty("get_attributes") private final Set attributes; + /** + * Constructs a new SearchById operation with the specified database, table, IDs, and attributes. + * + * @param database The name of the database where records will be searched. + * @param table The name of the table where records will be searched. + * @param ids The set of IDs used to identify and retrieve specific records. + * @param attributes The set of attributes to retrieve for each record. + */ SearchById(String database, String table, Set ids, Set attributes) { super(OperationType.SEARCH_BY_ID); this.database = database; @@ -26,4 +39,33 @@ final class SearchById extends Operation{ this.ids = ids; this.attributes = attributes; } + + + @Override + public boolean equals(Object object) { + if (this == object) { + return true; + } + if (object == null || getClass() != object.getClass()) { + return false; + } + SearchById that = (SearchById) object; + return Objects.equals(database, that.database) && Objects.equals(table, that.table) + && Objects.equals(ids, that.ids) && Objects.equals(attributes, that.attributes); + } + + @Override + public int hashCode() { + return Objects.hash(database, table, ids, attributes); + } + + @Override + public String toString() { + return "SearchById{" + + "database='" + database + '\'' + + ", table='" + table + '\'' + + ", ids=" + ids + + ", attributes=" + attributes + + '}'; + } }