public interface Document extends StringObjectMap<Document>
Map. All iterators preserve
original insertion order.
Document does not allow null keys. It allows null values.
Implementing classes can bei either mutable or immutable. In case a subclass is immutable, its methods may throw
UnsupportedOperationException when calling modifying methods.
| Modifier and Type | Method and Description |
|---|---|
static Document |
create()
Create a new mutable
Document. |
static Document |
from(Map<String,? extends Object> map)
|
default Document |
fromJson(String json)
initializes this object from the given JSON String.
|
default String |
getId()
Retrieve the identifier associated with this
Document. |
default String |
getIndex() |
default long |
getPrimaryTerm()
Retrieve the primary_term associated with this
Document. |
default long |
getSeqNo()
Retrieve the seq_no associated with this
Document. |
default long |
getVersion()
Retrieve the version associated with this
Document. |
default boolean |
hasId()
Return true if this
Document is associated with an identifier. |
default boolean |
hasPrimaryTerm()
Return true if this
Document is associated with a primary_term. |
default boolean |
hasSeqNo()
Return true if this
Document is associated with a seq_no. |
default boolean |
hasVersion()
Return true if this
Document is associated with a version. |
static Document |
parse(String json)
Parse JSON to
Document. |
default void |
setId(String id)
Set the identifier for this
Document. |
default void |
setIndex(String index)
Sets the index name for this document
|
default void |
setPrimaryTerm(long primaryTerm)
Set the primary_term for this
Document. |
default void |
setSeqNo(long seqNo)
Set the seq_no for this
Document. |
default void |
setVersion(long version)
Set the version for this
Document. |
default <R> R |
transform(Function<? super Document,? extends R> transformer)
This method allows the application of a function to
this Document. |
append, get, getBoolean, getBooleanOrDefault, getBooleanOrDefault, getInt, getIntOrDefault, getIntOrDefault, getLong, getLongOrDefault, getLongOrDefault, getString, getStringOrDefault, getStringOrDefault, toJsonclear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesstatic Document from(Map<String,? extends Object> map)
map - source map containing key-value pairs and sub-documents. must not be null.Document.static Document parse(String json)
Document.json - must not be null.Document.default Document fromJson(String json)
StringObjectMapfromJson in interface StringObjectMap<Document>json - must not be nulldefault boolean hasId()
Document is associated with an identifier.Document is associated with an identifier, false otherwise.@Nullable default String getIndex()
default void setIndex(@Nullable String index)
index - index name
The default implementation throws UnsupportedOperationException.
default String getId()
Document.
The default implementation throws UnsupportedOperationException. It's recommended to check hasId()
prior to calling this method.
Document.IllegalStateException - if the underlying implementation supports Id's but no Id was yet associated with the
document.default void setId(String id)
Document.
The default implementation throws UnsupportedOperationException.
default boolean hasVersion()
Document is associated with a version.Document is associated with a version, false otherwise.default long getVersion()
Document.
The default implementation throws UnsupportedOperationException. It's recommended to check
hasVersion() prior to calling this method.
Document.IllegalStateException - if the underlying implementation supports Id's but no Id was yet associated with the
document.default void setVersion(long version)
Document.
The default implementation throws UnsupportedOperationException.
default boolean hasSeqNo()
Document is associated with a seq_no.Document is associated with a seq_no, false otherwise.default long getSeqNo()
Document.
The default implementation throws UnsupportedOperationException. It's recommended to check
hasSeqNo() prior to calling this method.
Document.IllegalStateException - if the underlying implementation supports seq_no's but no seq_no was yet associated
with the document.default void setSeqNo(long seqNo)
Document.
The default implementation throws UnsupportedOperationException.
default boolean hasPrimaryTerm()
Document is associated with a primary_term.Document is associated with a primary_term, false otherwise.default long getPrimaryTerm()
Document.
The default implementation throws UnsupportedOperationException. It's recommended to check
hasPrimaryTerm() prior to calling this method.
Document.IllegalStateException - if the underlying implementation supports primary_term's but no primary_term was yet
associated with the document.default void setPrimaryTerm(long primaryTerm)
Document.
The default implementation throws UnsupportedOperationException.
default <R> R transform(Function<? super Document,? extends R> transformer)
this Document. The function should expect a
single Document argument and produce an R result.
Any exception thrown by the function will be propagated to the caller.
R - class of the resulttransformer - functional interface to a apply. must not be null.FunctionCopyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.