Class Document

  • All Implemented Interfaces:
    java.lang.Iterable<BaseDocument.Entry>

    public final class Document
    extends BaseDocument
    Represents an immutable document with an ID, associated collection, timestamp, and optional key-value data. This class extends BaseDocument to provide additional document-specific functionality, such as unique identification and data equality checks.
    • Constructor Summary

      Constructors 
      Constructor Description
      Document​(java.lang.String id, Module coll, java.time.Instant ts)
      Initializes a new instance of the Document class with the specified ID, collection, and timestamp.
      Document​(java.lang.String id, Module coll, java.time.Instant ts, java.util.Map<java.lang.String,​java.lang.Object> data)
      Initializes a new instance of the Document class with the specified ID, collection, timestamp, and additional key-value data.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)
      Checks if this document is equal to another object.
      java.lang.String getId()
      Gets the unique identifier for this document.
      int hashCode()
      Returns a hash code value for this document based on its ID, timestamp, collection, and data.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • Document

        public Document​(java.lang.String id,
                        Module coll,
                        java.time.Instant ts)
        Initializes a new instance of the Document class with the specified ID, collection, and timestamp.
        Parameters:
        id - The unique string identifier of the document.
        coll - The module (collection) to which the document belongs.
        ts - The timestamp indicating the document's creation or last modification.
      • Document

        public Document​(java.lang.String id,
                        Module coll,
                        java.time.Instant ts,
                        java.util.Map<java.lang.String,​java.lang.Object> data)
        Initializes a new instance of the Document class with the specified ID, collection, timestamp, and additional key-value data.
        Parameters:
        id - The unique string identifier of the document.
        coll - The module (collection) to which the document belongs.
        ts - The timestamp indicating the document's creation or last modification.
        data - Additional data for the document, represented as a map of key-value pairs.
    • Method Detail

      • getId

        public java.lang.String getId()
        Gets the unique identifier for this document.
        Returns:
        A String representing the document's unique ID.
      • equals

        public boolean equals​(java.lang.Object o)
        Checks if this document is equal to another object. Two documents are considered equal if they have the same ID, timestamp, collection, and data content.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - The object to compare with this document for equality.
        Returns:
        true if the specified object is equal to this document; otherwise, false.
      • hashCode

        public int hashCode()
        Returns a hash code value for this document based on its ID, timestamp, collection, and data.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        An integer hash code for this document.