Class BaseDocument

  • All Implemented Interfaces:
    java.lang.Iterable<BaseDocument.Entry>
    Direct Known Subclasses:
    Document, NamedDocument

    public abstract class BaseDocument
    extends java.lang.Object
    implements java.lang.Iterable<BaseDocument.Entry>
    Represents the base structure of a document with key-value pairs, a timestamp, and an associated collection. This class provides functionality to store, retrieve, and iterate over document data.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  BaseDocument.Entry
      Represents a key-value pair in the document.
    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean containsKey​(java.lang.String key)
      Determines whether the document contains the specified key.
      java.lang.Object get​(java.lang.String key)
      Retrieves the value associated with the specified key.
      Module getCollection()
      Gets the collection to which this document belongs.
      java.util.Map<java.lang.String,​java.lang.Object> getData()
      Retrieves a copy of the document's data as a Map.
      java.time.Instant getTs()
      Gets the timestamp of the document, indicating its creation or last modification time.
      java.util.Iterator<BaseDocument.Entry> iterator()
      Returns an iterator over the entries in this document.
      int size()
      Returns the number of key-value pairs contained in the document.
      • Methods inherited from class java.lang.Object

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

        forEach, spliterator
    • Constructor Detail

      • BaseDocument

        public BaseDocument​(Module coll,
                            java.time.Instant ts)
        Initializes a new instance of the BaseDocument class with the specified collection and timestamp.
        Parameters:
        coll - The collection to which the document belongs.
        ts - The timestamp indicating when the document was created or last modified.
      • BaseDocument

        public BaseDocument​(Module coll,
                            java.time.Instant ts,
                            java.util.Map<java.lang.String,​java.lang.Object> data)
        Initializes a new instance of the BaseDocument class with the specified collection, timestamp, and initial data.
        Parameters:
        coll - The collection to which the document belongs.
        ts - The timestamp of the document.
        data - Initial data for the document represented as key-value pairs.
    • Method Detail

      • iterator

        public java.util.Iterator<BaseDocument.Entry> iterator()
        Returns an iterator over the entries in this document. Each entry represents a key-value pair in the document's data.
        Specified by:
        iterator in interface java.lang.Iterable<BaseDocument.Entry>
        Returns:
        an Iterator<Entry> over the elements in this document.
      • getTs

        public java.time.Instant getTs()
        Gets the timestamp of the document, indicating its creation or last modification time.
        Returns:
        An Instant representing the document's timestamp.
      • getCollection

        public Module getCollection()
        Gets the collection to which this document belongs.
        Returns:
        The Module representing the document's collection.
      • getData

        public java.util.Map<java.lang.String,​java.lang.Object> getData()
        Retrieves a copy of the document's data as a Map.
        Returns:
        A Map<String, Object> containing the document's key-value pairs.
      • size

        public int size()
        Returns the number of key-value pairs contained in the document.
        Returns:
        The total number of key-value pairs in the document.
      • containsKey

        public boolean containsKey​(java.lang.String key)
        Determines whether the document contains the specified key.
        Parameters:
        key - The key to search for in the document.
        Returns:
        true if the document contains an element with the specified key; otherwise, false.
      • get

        public java.lang.Object get​(java.lang.String key)
        Retrieves the value associated with the specified key.
        Parameters:
        key - The key of the value to retrieve.
        Returns:
        The value associated with the specified key, or null if the key is not present.