@NotThreadSafe public interface Document extends Iterable<Document.Field>, Comparable<Document>
Document.Fields, each with a name and possibly-null Value. A single document can only
contain a single field with a given name.| Modifier and Type | Interface and Description |
|---|---|
static interface |
Document.Field |
| Modifier and Type | Method and Description |
|---|---|
default Stream<Document.Field> |
children(Path path)
Find a document at the given path and obtain a stream over its fields.
|
default Stream<Document.Field> |
children(String fieldName)
Find the document at the given field name and obtain a stream over its fields.
|
void |
clear()
Remove all fields from this document.
|
Document |
clone()
Obtain a clone of this document.
|
int |
compareTo(Document that)
Compare this Document to the specified Document, taking into account the order of the fields.
|
int |
compareTo(Document that,
boolean enforceFieldOrder)
Compare this Document to the specified Document, optionally comparing the fields in the same order.
|
int |
compareToUsingSimilarFields(Document that)
Compare this Document to the specified Document, without regard to the order of the fields and only using the fields
that are in both documents.
|
int |
compareToWithoutFieldOrder(Document that)
Compare this Document to the specified Document, without regard to the order of the fields.
|
static Document |
create() |
static Document |
create(CharSequence fieldName,
Object value) |
static Document |
create(CharSequence fieldName1,
Object value1,
CharSequence fieldName2,
Object value2) |
static Document |
create(CharSequence fieldName1,
Object value1,
CharSequence fieldName2,
Object value2,
CharSequence fieldName3,
Object value3) |
static Document |
create(CharSequence fieldName1,
Object value1,
CharSequence fieldName2,
Object value2,
CharSequence fieldName3,
Object value3,
CharSequence fieldName4,
Object value4) |
static Document |
create(CharSequence fieldName1,
Object value1,
CharSequence fieldName2,
Object value2,
CharSequence fieldName3,
Object value3,
CharSequence fieldName4,
Object value4,
CharSequence fieldName5,
Object value5) |
static Document |
create(CharSequence fieldName1,
Object value1,
CharSequence fieldName2,
Object value2,
CharSequence fieldName3,
Object value3,
CharSequence fieldName4,
Object value4,
CharSequence fieldName5,
Object value5,
CharSequence fieldName6,
Object value6) |
static Document.Field |
field(String name,
Object value) |
static Document.Field |
field(String name,
Value value) |
default Optional<Value> |
find(Path path)
Attempt to find the value at the given path.
|
default Optional<Value> |
find(Path path,
BiFunction<Path,Integer,Optional<Value>> missingSegment,
Consumer<Path> invalid)
Attempt to find the value at the given path, optionally creating missing segments.
|
default void |
forEach(BiConsumer<Path,Value> consumer) |
default Value |
get(CharSequence fieldName)
Gets the value in this document for the given field name.
|
Value |
get(CharSequence fieldName,
Comparable<?> defaultValue)
Gets the value in this document for the given field name.
|
default Array |
getArray(CharSequence fieldName)
Get the array value in this document for the given field name.
|
default Array |
getArray(CharSequence fieldName,
Array defaultValue)
Get the array value in this document for the given field name.
|
default BigDecimal |
getBigDecimal(CharSequence fieldName)
Get the big decimal value in this document for the given field name.
|
default BigDecimal |
getBigDecimal(CharSequence fieldName,
BigDecimal defaultValue)
Get the big decimal value in this document for the given field name.
|
default BigInteger |
getBigInteger(CharSequence fieldName)
Get the big integer value in this document for the given field name.
|
default BigInteger |
getBigInteger(CharSequence fieldName,
BigInteger defaultValue)
Get the big integer value in this document for the given field name.
|
default Boolean |
getBoolean(CharSequence fieldName)
Get the boolean value in this document for the given field name.
|
default boolean |
getBoolean(CharSequence fieldName,
boolean defaultValue)
Get the boolean value in this document for the given field name.
|
default byte[] |
getBytes(CharSequence fieldName)
Get the Base64 encoded binary value in this document for the given field name.
|
default Document |
getDocument(CharSequence fieldName)
Get the document value in this document for the given field name.
|
default Double |
getDouble(CharSequence fieldName)
Get the double value in this document for the given field name.
|
default double |
getDouble(CharSequence fieldName,
double defaultValue)
Get the double value in this document for the given field name.
|
default Document.Field |
getField(CharSequence fieldName)
Gets the field in this document with the given field name.
|
default Float |
getFloat(CharSequence fieldName)
Get the double value in this document for the given field name.
|
default float |
getFloat(CharSequence fieldName,
float defaultValue)
Get the float value in this document for the given field name.
|
default Integer |
getInteger(CharSequence fieldName)
Get the integer value in this document for the given field name.
|
default int |
getInteger(CharSequence fieldName,
int defaultValue)
Get the integer value in this document for the given field name.
|
default Long |
getLong(CharSequence fieldName)
Get the integer value in this document for the given field name.
|
default long |
getLong(CharSequence fieldName,
long defaultValue)
Get the long value in this document for the given field name.
|
default Number |
getNumber(CharSequence fieldName)
Get the number value in this document for the given field name.
|
default Number |
getNumber(CharSequence fieldName,
Number defaultValue)
Get the number value in this document for the given field name.
|
default Array |
getOrCreateArray(CharSequence fieldName)
Get the existing array value in this document for the given field name, or create a new array if there is no existing array
at this field.
|
default Document |
getOrCreateDocument(CharSequence fieldName)
Get the existing document value in this document for the given field name, or create a new document if there is no existing
document at this field.
|
default String |
getString(CharSequence fieldName)
Get the string value in this document for the given field name.
|
default String |
getString(CharSequence fieldName,
String defaultValue)
Get the string value in this document for the given field name.
|
boolean |
has(CharSequence fieldName)
Determine if this contains a field with the given name.
|
boolean |
hasAll(Document document)
Checks if this object contains all of the fields in the supplied document.
|
default Document |
increment(CharSequence name,
double increment)
Increment the numeric value in the given field by the designated amount.
|
default Document |
increment(CharSequence name,
float increment)
Increment the numeric value in the given field by the designated amount.
|
default Document |
increment(CharSequence name,
int increment)
Increment the numeric value in the given field by the designated amount.
|
default Document |
increment(CharSequence name,
long increment)
Increment the numeric value in the given field by the designated amount.
|
Document |
increment(CharSequence name,
Value increment)
Increment the numeric value in the given field by the designated amount.
|
boolean |
isEmpty()
Return whether this document contains no fields and is therefore empty.
|
default boolean |
isNull(CharSequence fieldName)
Determine whether this object has a field with the given the name and the value is null.
|
default boolean |
isNullOrMissing(CharSequence fieldName)
Determine whether this object has a field with the given the name and the value is null, or if this object has no field
with
the given name.
|
Iterable<CharSequence> |
keySet()
Returns this object's fields' names
|
default Document |
putAll(Iterable<Document.Field> fields)
Sets on this object all name/value pairs from the supplied object.
|
default Document |
putAll(Iterable<Document.Field> fields,
Predicate<CharSequence> acceptableFieldNames)
Attempts to copy all of the acceptable fields from the source and set on this document, overwriting any existing
values.
|
default Document |
putAll(Iterator<Document.Field> fields)
Sets on this object all name/value pairs from the supplied object.
|
default Document |
putAll(Map<? extends CharSequence,?> fields)
Sets on this object all key/value pairs from the supplied map.
|
Value |
remove(CharSequence name)
Remove the field with the supplied name, and return the value.
|
default Value |
remove(Optional<? extends CharSequence> name)
If the supplied name is provided, then remove the field with the supplied name and return the value.
|
Document |
removeAll()
Remove all fields from this document.
|
default Document |
set(CharSequence name,
Object value)
Set the value for the field with the given name to be a binary value.
|
default Optional<Value> |
set(Path path,
boolean addIntermediaries,
Value value,
Consumer<Path> invalid)
Set the value at the given path resolved against this document, optionally adding any missing intermediary documents
or arrays based upon the format of the path segments.
|
default Array |
setArray(CharSequence name)
Set the value for the field with the given name to be a new, empty array.
|
default Array |
setArray(CharSequence name,
Array array)
Set the value for the field with the given name to be the supplied array.
|
default Array |
setArray(CharSequence name,
Object... values)
Set the value for the field with the given name to be the supplied array.
|
default Document |
setBinary(CharSequence name,
byte[] data)
Set the value for the field with the given name to be a binary value.
|
default Document |
setBoolean(CharSequence name,
boolean value)
Set the value for the field with the given name to the supplied boolean value.
|
default Document |
setDocument(CharSequence name)
Set the value for the field with the given name to be a new, empty Document.
|
default Document |
setDocument(CharSequence name,
Document document)
Set the value for the field with the given name to be the supplied Document.
|
default Document |
setNull(CharSequence name)
Set the value for the field with the given name to be a null value.
|
default Document |
setNumber(CharSequence name,
BigDecimal value)
Set the value for the field with the given name to the supplied big integer value.
|
default Document |
setNumber(CharSequence name,
BigInteger value)
Set the value for the field with the given name to the supplied big integer value.
|
default Document |
setNumber(CharSequence name,
double value)
Set the value for the field with the given name to the supplied double value.
|
default Document |
setNumber(CharSequence name,
float value)
Set the value for the field with the given name to the supplied float value.
|
default Document |
setNumber(CharSequence name,
int value)
Set the value for the field with the given name to the supplied integer value.
|
default Document |
setNumber(CharSequence name,
long value)
Set the value for the field with the given name to the supplied long value.
|
default Document |
setString(CharSequence name,
String value)
Set the value for the field with the given name to the supplied string value.
|
Document |
setValue(CharSequence name,
Value value)
Set the value for the field with the given name.
|
default Document |
setValue(Document.Field field)
Set the field on this document.
|
int |
size()
Return the number of name-value fields in this object.
|
default Stream<Document.Field> |
stream()
Returns a sequential
Stream with this array as its source. |
default Document |
transform(BiFunction<CharSequence,Value,Value> transformer)
Transform all of the field values using the supplied
transformer function. |
forEach, iterator, spliteratorstatic Document.Field field(String name, Value value)
static Document.Field field(String name, Object value)
static Document create()
static Document create(CharSequence fieldName, Object value)
static Document create(CharSequence fieldName1, Object value1, CharSequence fieldName2, Object value2)
static Document create(CharSequence fieldName1, Object value1, CharSequence fieldName2, Object value2, CharSequence fieldName3, Object value3)
static Document create(CharSequence fieldName1, Object value1, CharSequence fieldName2, Object value2, CharSequence fieldName3, Object value3, CharSequence fieldName4, Object value4)
static Document create(CharSequence fieldName1, Object value1, CharSequence fieldName2, Object value2, CharSequence fieldName3, Object value3, CharSequence fieldName4, Object value4, CharSequence fieldName5, Object value5)
static Document create(CharSequence fieldName1, Object value1, CharSequence fieldName2, Object value2, CharSequence fieldName3, Object value3, CharSequence fieldName4, Object value4, CharSequence fieldName5, Object value5, CharSequence fieldName6, Object value6)
int size()
boolean isEmpty()
void clear()
boolean has(CharSequence fieldName)
fieldName - The name of the fieldboolean hasAll(Document document)
document - The document with the fields that should be in this documentdefault Optional<Value> set(Path path, boolean addIntermediaries, Value value, Consumer<Path> invalid)
path - the path at which the value is to be setaddIntermediaries - true if any missing intermediary fields should be created, or false if any missing
intermediary fields should be handled as an error via invalidvalue - the value that should be set at the given path; may be null or a null valueinvalid - the function that should be called if the supplied path cannot be resolved; may not be nullvalue if successful or the empty (not present) optional value if
the path was invalid and could not be resolved (and invalid is invoked)default Optional<Value> find(Path path)
path - the path to findpresent if the value was found at that
path or is empty (not present) if there is no value at the path or if the path was not
validdefault Optional<Value> find(Path path, BiFunction<Path,Integer,Optional<Value>> missingSegment, Consumer<Path> invalid)
path - the path to findmissingSegment - function called when a segment in the path does not exist, and which should return a new value
if one should be created or Optional.empty() if nothing should be created and invalid function
should be called by this methodinvalid - function called when the supplied path is invalid; in this case, this method also returns
Optional.empty()present if the value was found at that
path or is empty (not present) if there is no value at the path or if the path was not
validdefault Stream<Document.Field> children(Path path)
path - the path to the contained documentdefault Stream<Document.Field> children(String fieldName)
fieldName - the path to the contained documentdefault Document.Field getField(CharSequence fieldName)
fieldName - The name of the fielddefault Value get(CharSequence fieldName)
fieldName - The name of the fieldValue get(CharSequence fieldName, Comparable<?> defaultValue)
fieldName - The name of the fielddefaultValue - the default value to return if there is no such fielddefaultValue if there is no such fielddefault Boolean getBoolean(CharSequence fieldName)
fieldName - The name of the fielddefault boolean getBoolean(CharSequence fieldName, boolean defaultValue)
fieldName - The name of the fielddefaultValue - the default value to return if there is no such field or if the value is not a booleandefaultValue if there is no such field or if the value is not a
booleandefault Integer getInteger(CharSequence fieldName)
fieldName - The name of the fielddefault int getInteger(CharSequence fieldName, int defaultValue)
fieldName - The name of the fielddefaultValue - the default value to return if there is no such field or if the value is not a integerdefaultValue if there is no such field or if the value is not a
integerdefault Long getLong(CharSequence fieldName)
fieldName - The name of the fielddefault long getLong(CharSequence fieldName, long defaultValue)
fieldName - The name of the fielddefaultValue - the default value to return if there is no such field or if the value is not a long valuedefaultValue if there is no such field or if the value is not a long
valuedefault Double getDouble(CharSequence fieldName)
fieldName - The name of the fielddefault double getDouble(CharSequence fieldName, double defaultValue)
fieldName - The name of the fielddefaultValue - the default value to return if there is no such field or if the value is not a doubledefaultValue if there is no such field or if the value is not a
doubledefault Float getFloat(CharSequence fieldName)
fieldName - The name of the fielddefault float getFloat(CharSequence fieldName, float defaultValue)
fieldName - The name of the fielddefaultValue - the default value to return if there is no such field or if the value is not a doubledefaultValue if there is no such field or if the value is not a
doubledefault Number getNumber(CharSequence fieldName)
fieldName - The name of the fielddefault Number getNumber(CharSequence fieldName, Number defaultValue)
fieldName - The name of the fielddefaultValue - the default value to return if there is no such field or if the value is not a numberdefaultValue if there is no such field or if the value is not a
numberdefault BigInteger getBigInteger(CharSequence fieldName)
fieldName - The name of the fielddefault BigInteger getBigInteger(CharSequence fieldName, BigInteger defaultValue)
fieldName - The name of the fielddefaultValue - the default value to return if there is no such field or if the value is not a big integerdefault BigDecimal getBigDecimal(CharSequence fieldName)
fieldName - The name of the fielddefault BigDecimal getBigDecimal(CharSequence fieldName, BigDecimal defaultValue)
fieldName - The name of the fielddefaultValue - the default value to return if there is no such field or if the value is not a big decimaldefault String getString(CharSequence fieldName)
fieldName - The name of the fielddefault String getString(CharSequence fieldName, String defaultValue)
fieldName - The name of the fielddefaultValue - the default value to return if there is no such field or if the value is not a stringdefaultValue if there is no such field or if the value is not a
stringdefault byte[] getBytes(CharSequence fieldName)
fieldName - The name of the fielddefault Array getArray(CharSequence fieldName)
fieldName - The name of the fielddefault Array getArray(CharSequence fieldName, Array defaultValue)
fieldName - The name of the fielddefaultValue - the default array that should be returned if there is no such fielddefault Array getOrCreateArray(CharSequence fieldName)
fieldName - The name of the fielddefault Document getDocument(CharSequence fieldName)
fieldName - The name of the fielddefault Document getOrCreateDocument(CharSequence fieldName)
fieldName - The name of the fielddefault boolean isNull(CharSequence fieldName)
this.get(name) instanceof Null;
fieldName - The name of the fieldtrue if the field exists but is null, or false otherwiseisNullOrMissing(CharSequence)default boolean isNullOrMissing(CharSequence fieldName)
Null.matches(this.get(name));
fieldName - The name of the fieldtrue if the field value for the name is null or if there is no such field.isNull(CharSequence)Iterable<CharSequence> keySet()
Document clone()
Value remove(CharSequence name)
name - The name of the fielddefault Value remove(Optional<? extends CharSequence> name)
name - The optional name of the fieldDocument removeAll()
default Document putAll(Iterator<Document.Field> fields)
fields - the name/value pairs to be set on this object; may not be nulldefault Document putAll(Iterable<Document.Field> fields)
fields - the name/value pairs to be set on this object; may not be nulldefault Document putAll(Iterable<Document.Field> fields, Predicate<CharSequence> acceptableFieldNames)
fields - the name/value pairs to be set on this object; may not be nullacceptableFieldNames - the predicate to determine which fields from the source should be copied; may not be nulldefault Document putAll(Map<? extends CharSequence,?> fields)
fields - the map containing the name/value pairs to be set on this objectdefault Stream<Document.Field> stream()
Stream with this array as its source.Stream over the elements in this collectiondefault void forEach(BiConsumer<Path,Value> consumer)
default Document transform(BiFunction<CharSequence,Value,Value> transformer)
transformer function.transformer - the transformer that should be used to transform each field value; may not be nulldefault Document set(CharSequence name, Object value)
name - The name of the fieldvalue - the new valuedefault Document setNull(CharSequence name)
isNull(CharSequence) methods can be used
to
determine if a field has been set to null, or isNullOrMissing(CharSequence) if the field has not be set or if it
has
been set to null.name - The name of the fieldisNull(CharSequence),
isNullOrMissing(CharSequence)default Document setBoolean(CharSequence name, boolean value)
name - The name of the fieldvalue - the new value for the fielddefault Document setNumber(CharSequence name, int value)
name - The name of the fieldvalue - the new value for the fielddefault Document setNumber(CharSequence name, long value)
name - The name of the fieldvalue - the new value for the fielddefault Document setNumber(CharSequence name, float value)
name - The name of the fieldvalue - the new value for the fielddefault Document setNumber(CharSequence name, double value)
name - The name of the fieldvalue - the new value for the fielddefault Document setNumber(CharSequence name, BigInteger value)
name - The name of the fieldvalue - the new value for the fielddefault Document setNumber(CharSequence name, BigDecimal value)
name - The name of the fieldvalue - the new value for the fielddefault Document setString(CharSequence name, String value)
name - The name of the fieldvalue - the new value for the fielddefault Document increment(CharSequence name, int increment)
name - The name of the fieldincrement - the amount to increment the existing value; may be negative to decrementIllegalArgumentException - if the current value is not a numberdefault Document increment(CharSequence name, long increment)
name - The name of the fieldincrement - the amount to increment the existing value; may be negative to decrementIllegalArgumentException - if the current value is not a numberdefault Document increment(CharSequence name, double increment)
name - The name of the fieldincrement - the amount to increment the existing value; may be negative to decrementIllegalArgumentException - if the current value is not a numberdefault Document increment(CharSequence name, float increment)
name - The name of the fieldincrement - the amount to increment the existing value; may be negative to decrementIllegalArgumentException - if the current value is not a numberDocument increment(CharSequence name, Value increment)
name - The name of the fieldincrement - the amount to increment the existing value; may be negative to decrementIllegalArgumentException - if the current value is not a numberdefault Document setBinary(CharSequence name, byte[] data)
name - The name of the fielddata - the bytes for the binary valueDocument setValue(CharSequence name, Value value)
name - The name of the fieldvalue - the new valuedefault Document setValue(Document.Field field)
field - The fielddefault Document setDocument(CharSequence name)
name - The name of the fielddefault Document setDocument(CharSequence name, Document document)
name - The name of the fielddocument - the document; if null, a new document will be createddocument.default Array setArray(CharSequence name)
name - The name of the fielddefault Array setArray(CharSequence name, Array array)
name - The name of the fieldarray - the arrayarray.default Array setArray(CharSequence name, Object... values)
name - The name of the fieldvalues - the (valid) values for the arrayarray.int compareTo(Document that)
compareTo in interface Comparable<Document>that - the other Document to be compared to this objectint compareToWithoutFieldOrder(Document that)
that - the other Document to be compared to this objectint compareToUsingSimilarFields(Document that)
that - the other Document to be compared to this objectint compareTo(Document that, boolean enforceFieldOrder)
that - the other Document to be compared to this objectenforceFieldOrder - true if the documents should be compared using their existing field order, or
false if the field order should not affect the result.Copyright © 2021 JBoss by Red Hat. All rights reserved.