Package com.fauna.types
Class BaseDocument
- java.lang.Object
-
- com.fauna.types.BaseDocument
-
- All Implemented Interfaces:
java.lang.Iterable<BaseDocument.Entry>
- Direct Known Subclasses:
Document,NamedDocument
public abstract class BaseDocument extends java.lang.Object implements java.lang.Iterable<BaseDocument.Entry>
Represents the base structure of a document with key-value pairs, a timestamp, and an associated collection. This class provides functionality to store, retrieve, and iterate over document data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBaseDocument.EntryRepresents a key-value pair in the document.
-
Constructor Summary
Constructors Constructor Description BaseDocument(Module coll, java.time.Instant ts)Initializes a new instance of theBaseDocumentclass with the specified collection and timestamp.BaseDocument(Module coll, java.time.Instant ts, java.util.Map<java.lang.String,java.lang.Object> data)Initializes a new instance of theBaseDocumentclass with the specified collection, timestamp, and initial data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(java.lang.String key)Determines whether the document contains the specified key.java.lang.Objectget(java.lang.String key)Retrieves the value associated with the specified key.ModulegetCollection()Gets the collection to which this document belongs.java.util.Map<java.lang.String,java.lang.Object>getData()Retrieves a copy of the document's data as aMap.java.time.InstantgetTs()Gets the timestamp of the document, indicating its creation or last modification time.java.util.Iterator<BaseDocument.Entry>iterator()Returns an iterator over the entries in this document.intsize()Returns the number of key-value pairs contained in the document.
-
-
-
Constructor Detail
-
BaseDocument
public BaseDocument(Module coll, java.time.Instant ts)
Initializes a new instance of theBaseDocumentclass with the specified collection and timestamp.- Parameters:
coll- The collection to which the document belongs.ts- The timestamp indicating when the document was created or last modified.
-
BaseDocument
public BaseDocument(Module coll, java.time.Instant ts, java.util.Map<java.lang.String,java.lang.Object> data)
Initializes a new instance of theBaseDocumentclass with the specified collection, timestamp, and initial data.- Parameters:
coll- The collection to which the document belongs.ts- The timestamp of the document.data- Initial data for the document represented as key-value pairs.
-
-
Method Detail
-
iterator
public java.util.Iterator<BaseDocument.Entry> iterator()
Returns an iterator over the entries in this document. Each entry represents a key-value pair in the document's data.- Specified by:
iteratorin interfacejava.lang.Iterable<BaseDocument.Entry>- Returns:
- an
Iterator<Entry>over the elements in this document.
-
getTs
public java.time.Instant getTs()
Gets the timestamp of the document, indicating its creation or last modification time.- Returns:
- An
Instantrepresenting the document's timestamp.
-
getCollection
public Module getCollection()
Gets the collection to which this document belongs.- Returns:
- The
Modulerepresenting the document's collection.
-
getData
public java.util.Map<java.lang.String,java.lang.Object> getData()
Retrieves a copy of the document's data as aMap.- Returns:
- A
Map<String, Object>containing the document's key-value pairs.
-
size
public int size()
Returns the number of key-value pairs contained in the document.- Returns:
- The total number of key-value pairs in the document.
-
containsKey
public boolean containsKey(java.lang.String key)
Determines whether the document contains the specified key.- Parameters:
key- The key to search for in the document.- Returns:
trueif the document contains an element with the specified key; otherwise,false.
-
get
public java.lang.Object get(java.lang.String key)
Retrieves the value associated with the specified key.- Parameters:
key- The key of the value to retrieve.- Returns:
- The value associated with the specified key, or
nullif the key is not present.
-
-