Class NullableDocument<T>

  • Type Parameters:
    T - The type of the document's content.
    Direct Known Subclasses:
    NonNullDocument, NullDocument

    public abstract class NullableDocument<T>
    extends java.lang.Object
    Represents a generic document wrapper that may hold a value representing a document. This abstract class provides a base for documents that can optionally hold a value.
    • Constructor Summary

      Constructors 
      Constructor Description
      NullableDocument()
      Constructs a NullableDocument without a value, initializing it to null.
      NullableDocument​(T val)
      Constructs a NullableDocument with the specified value.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract T get()
      Retrieves the document's value.
      protected T getUnderlyingValue()
      Provides protected access to the underlying value, allowing subclasses to directly access the stored value without additional logic.
      • Methods inherited from class java.lang.Object

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

      • NullableDocument

        public NullableDocument()
        Constructs a NullableDocument without a value, initializing it to null.
      • NullableDocument

        public NullableDocument​(T val)
        Constructs a NullableDocument with the specified value.
        Parameters:
        val - The value to wrap, which may be null.
    • Method Detail

      • get

        public abstract T get()
        Retrieves the document's value. This method must be implemented by subclasses to specify how the value should be accessed.
        Returns:
        The document's content of type T.
      • getUnderlyingValue

        protected T getUnderlyingValue()
        Provides protected access to the underlying value, allowing subclasses to directly access the stored value without additional logic.
        Returns:
        The underlying value of type T, which may be null.