Package com.fauna.types
Class NonNullDocument<T>
- java.lang.Object
-
- com.fauna.types.NullableDocument<T>
-
- com.fauna.types.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 extendsNullableDocument
and enforces non-null data for the document by disallowing null values in its constructor.
-
-
Constructor Summary
Constructors Constructor Description NonNullDocument(T val)
Constructs aNonNullDocument
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 com.fauna.types.NullableDocument
getUnderlyingValue
-
-
-
-
Constructor Detail
-
NonNullDocument
public NonNullDocument(T val)
Constructs aNonNullDocument
with the specified non-null value.- Parameters:
val
- The document's content of typeT
. Must not be null.- Throws:
java.lang.NullPointerException
- ifval
is null.
-
-
Method Detail
-
get
public T get()
Retrieves the non-null wrapped value of the document.- Specified by:
get
in classNullableDocument<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. TwoNonNullDocument
objects are considered equal if they hold values of the same type and content.- Overrides:
equals
in classjava.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 classjava.lang.Object
- Returns:
- An integer hash code for this document.
-
-