Class NonNullDocument<T>

  • Type Parameters:
    T - The type of the document content.

    public final class NonNullDocument<T>
    extends NullableDocument<T>
    Represents a document that is guaranteed to have a non-null value. This class extends NullableDocument and enforces non-null data for the document by disallowing null values in its constructor.
    • Constructor Summary

      Constructors 
      Constructor Description
      NonNullDocument​(T val)
      Constructs a NonNullDocument with the specified non-null value.
    • 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.
      T get()
      Retrieves the non-null wrapped value of the document.
      T getValue()
      Retrieves the non-null wrapped value of the document.
      int hashCode()
      Returns a hash code value for this document based on its non-null value.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NonNullDocument

        public NonNullDocument​(T val)
        Constructs a NonNullDocument with the specified non-null value.
        Parameters:
        val - The document's content of type T. Must not be null.
        Throws:
        java.lang.NullPointerException - if val is null.
    • Method Detail

      • get

        public T get()
        Retrieves the non-null wrapped value of the document.
        Specified by:
        get in class NullableDocument<T>
        Returns:
        The non-null wrapped value of type T.
      • getValue

        public T getValue()
        Retrieves the non-null wrapped value of the document. This method provides compatibility for default serialization.
        Returns:
        The non-null wrapped value of type T.
      • equals

        public boolean equals​(java.lang.Object o)
        Checks if this document is equal to another object. Two NonNullDocument objects are considered equal if they hold values of the same type and 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 non-null value.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        An integer hash code for this document.