Package com.fauna.types
Class Document
- java.lang.Object
-
- com.fauna.types.BaseDocument
-
- com.fauna.types.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 extendsBaseDocumentto provide additional document-specific functionality, such as unique identification and data equality checks.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.fauna.types.BaseDocument
BaseDocument.Entry
-
-
Constructor Summary
Constructors Constructor Description Document(java.lang.String id, Module coll, java.time.Instant ts)Initializes a new instance of theDocumentclass 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 theDocumentclass with the specified ID, collection, timestamp, and additional key-value data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)Checks if this document is equal to another object.java.lang.StringgetId()Gets the unique identifier for this document.inthashCode()Returns a hash code value for this document based on its ID, timestamp, collection, and data.-
Methods inherited from class com.fauna.types.BaseDocument
containsKey, get, getCollection, getData, getTs, iterator, size
-
-
-
-
Constructor Detail
-
Document
public Document(java.lang.String id, Module coll, java.time.Instant ts)Initializes a new instance of theDocumentclass 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 theDocumentclass 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
Stringrepresenting 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:
equalsin classjava.lang.Object- Parameters:
o- The object to compare with this document for equality.- Returns:
trueif 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:
hashCodein classjava.lang.Object- Returns:
- An integer hash code for this document.
-
-