Gemfire JavaDocs_test
Package org.apache.geode.cache
Interface Document
-
- All Known Subinterfaces:
JsonDocument
,PdxInstance
,WritablePdxInstance
public interface Document
Users can implement this interface on classes they store in GemFire. The GemFire OQL query engine will handle objects that implement this interface in order to access fields.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Object
FIELD_NOT_FOUND
This Object is returned fromgetAndCheckField(String)
if the field does not exist.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
equals(java.lang.Object other)
Returns true if the given object is equals to this Document.default void
foreach(java.util.function.BiConsumer<java.lang.String,java.lang.Object> action)
For each field in this document callaction
with the field'sname
andvalue
.default java.lang.Object
getAndCheckField(java.lang.String fieldName)
Checks if the field exists and if it does returns its value.java.lang.Object
getField(java.lang.String fieldName)
Reads the named field and returns its value.java.util.List<java.lang.String>
getFieldNames()
Return an unmodifiable list of the field names.boolean
hasField(java.lang.String fieldName)
Checks if the named field exists and returns the result.int
hashCode()
Generates a hashCode based on all fields of this Document.
-
-
-
Field Detail
-
FIELD_NOT_FOUND
@Immutable static final java.lang.Object FIELD_NOT_FOUND
This Object is returned fromgetAndCheckField(String)
if the field does not exist.
-
-
Method Detail
-
hasField
boolean hasField(java.lang.String fieldName)
Checks if the named field exists and returns the result.- Parameters:
fieldName
- the name of the field to check- Returns:
true
if the named field exists; otherwisefalse
-
getFieldNames
java.util.List<java.lang.String> getFieldNames()
Return an unmodifiable list of the field names.- Returns:
- an unmodifiable list of the field names
-
getField
java.lang.Object getField(java.lang.String fieldName)
Reads the named field and returns its value. If the field does not existnull
is returned.A
null
result indicates that the field does not exist or that it exists and its value is currentlynull
. ThehasField
method can be used to figure out which of these two cases is true.- Parameters:
fieldName
- name of the field to read- Returns:
- If this instance has the named field then the field's value is returned, otherwise
null
is returned. - Throws:
java.lang.RuntimeException
- if the field could not be deserialized
-
equals
boolean equals(java.lang.Object other)
Returns true if the given object is equals to this Document.Otherwise equality of two Documents is determined as follows:
- Every field must be equal.
A field is equal if all the following are true:
- The field name is equal.
- The field value is equal.
A field's value may be deserialized to determine if it is equals.
- Overrides:
equals
in classjava.lang.Object
- Parameters:
other
- the other Document to compare to this.- Returns:
true
if this instance is equal toother
.
-
hashCode
int hashCode()
Generates a hashCode based on all fields of this Document.- Overrides:
hashCode
in classjava.lang.Object
-
getAndCheckField
default java.lang.Object getAndCheckField(java.lang.String fieldName)
Checks if the field exists and if it does returns its value. If the field does not exist returnsFIELD_NOT_FOUND
. Otherwise, behaves the same asgetField(String)
. Some implementations may provide an implementation of this which performs better than the default.- Parameters:
fieldName
- name of the field to read- Returns:
- If this instance has the named field then the field's possibly null value is returned,
otherwise
FIELD_NOT_FOUND
is returned. - Throws:
java.lang.RuntimeException
- if the field could not be deserialized
-
foreach
default void foreach(java.util.function.BiConsumer<java.lang.String,java.lang.Object> action)
For each field in this document callaction
with the field'sname
andvalue
. Some implementations may provide an implementation of this which performs better than the default.- Parameters:
action
- called for each field in this document
-
-