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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BaseDocument.Entry
Represents a key-value pair in the document.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Hashtable<java.lang.String,java.lang.Object>
data
-
Constructor Summary
Constructors Constructor Description BaseDocument(Module coll, java.time.Instant ts)
Initializes a new instance of theBaseDocument
class 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 theBaseDocument
class with the specified collection, timestamp, and initial data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(java.lang.String key)
Determines whether the document contains the specified key.java.lang.Object
get(java.lang.String key)
Gets the value associated with the specified key.Module
getCollection()
Gets the collection to which the document belongs.java.util.Map<java.lang.String,java.lang.Object>
getData()
Gets a copy of the underlying data as a Map.java.time.Instant
getTs()
Gets the timestamp of the document.java.util.Iterator<BaseDocument.Entry>
iterator()
Returns an iterator over the elements in this document.int
size()
Gets the count of key-value pairs contained in the document.
-
-
-
Constructor Detail
-
BaseDocument
public BaseDocument(Module coll, java.time.Instant ts)
Initializes a new instance of theBaseDocument
class with the specified collection and timestamp.- Parameters:
coll
- The collection to which the document belongs.ts
- The timestamp of the document.
-
BaseDocument
public BaseDocument(Module coll, java.time.Instant ts, java.util.Map<java.lang.String,java.lang.Object> data)
Initializes a new instance of theBaseDocument
class 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 in key-value pairs.
-
-
Method Detail
-
iterator
public java.util.Iterator<BaseDocument.Entry> iterator()
Returns an iterator over the elements in this document.- Specified by:
iterator
in interfacejava.lang.Iterable<BaseDocument.Entry>
- Returns:
- an iterator over the elements in this document.
-
getTs
public java.time.Instant getTs()
Gets the timestamp of the document.- Returns:
- The Instant of the document.
-
getCollection
public Module getCollection()
Gets the collection to which the document belongs.- Returns:
- The collection to which the document belongs.
-
getData
public java.util.Map<java.lang.String,java.lang.Object> getData()
Gets a copy of the underlying data as a Map.- Returns:
- The data.
-
size
public int size()
Gets the count of key-value pairs contained in the document.- Returns:
- The number of key-value pairs.
-
containsKey
public boolean containsKey(java.lang.String key)
Determines whether the document contains the specified key.- Parameters:
key
- The key to locate in the document.- Returns:
true
if the document contains an element with the specified key; otherwise,false
.
-
get
public java.lang.Object get(java.lang.String key)
Gets the value associated with the specified key.- Parameters:
key
- The key of the value to get.- Returns:
- The value associated with the specified key, or
null
if the key is not found.
-
-