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 extendsBaseDocument
to 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 theDocument
class 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 theDocument
class with the specified ID, collection, timestamp, and additional key-value data.
-
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.java.lang.String
getId()
Gets the unique identifier for this document.int
hashCode()
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 theDocument
class 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 theDocument
class 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
String
representing 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:
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 ID, timestamp, collection, and data.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- An integer hash code for this document.
-
-