Package com.fauna.types
Class NamedDocument
- java.lang.Object
-
- com.fauna.types.BaseDocument
-
- com.fauna.types.NamedDocument
-
- All Implemented Interfaces:
java.lang.Iterable<BaseDocument.Entry>
public final class NamedDocument extends BaseDocument
Represents a document identified by a "name" rather than an "id". This class is commonly used for documents in system collections where a unique name (e.g., for a Role) is more relevant than a numeric or auto-generated ID.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.fauna.types.BaseDocument
BaseDocument.Entry
-
-
Constructor Summary
Constructors Constructor Description NamedDocument(java.lang.String name, Module coll, java.time.Instant ts)Initializes a new instance of theNamedDocumentclass with the specified name, collection, and timestamp.NamedDocument(java.lang.String name, Module coll, java.time.Instant ts, java.util.Map<java.lang.String,java.lang.Object> data)Initializes a new instance of theNamedDocumentclass with the specified name, collection, timestamp, and additional 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.StringgetName()Gets the unique name of the document.inthashCode()Returns a hash code value for this document based on its name, timestamp, collection, and data.-
Methods inherited from class com.fauna.types.BaseDocument
containsKey, get, getCollection, getData, getTs, iterator, size
-
-
-
-
Constructor Detail
-
NamedDocument
public NamedDocument(java.lang.String name, Module coll, java.time.Instant ts)Initializes a new instance of theNamedDocumentclass with the specified name, collection, and timestamp.- Parameters:
name- The unique string name of the document.coll- The module (collection) to which the document belongs.ts- The timestamp indicating the document's creation or last modification.
-
NamedDocument
public NamedDocument(java.lang.String name, Module coll, java.time.Instant ts, java.util.Map<java.lang.String,java.lang.Object> data)Initializes a new instance of theNamedDocumentclass with the specified name, collection, timestamp, and additional data.- Parameters:
name- The unique string name 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 key-value data to store in the document.
-
-
Method Detail
-
getName
public java.lang.String getName()
Gets the unique name of the document.- Returns:
- A
Stringrepresenting the document's name.
-
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 name, timestamp, collection, and data.- 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 name, timestamp, collection, and data.- Overrides:
hashCodein classjava.lang.Object- Returns:
- An integer hash code for this document.
-
-