VMware GemFire Java API Reference
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
FieldsModifier and TypeFieldDescriptionstatic final ObjectThis Object is returned fromgetAndCheckField(String)if the field does not exist. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if the given object is equals to this Document.default voidforeach(BiConsumer<String, Object> action) For each field in this document callactionwith the field'snameandvalue.default ObjectgetAndCheckField(String fieldName) Checks if the field exists and if it does returns its value.Reads the named field and returns its value.Return an unmodifiable list of the field names.booleanChecks if the named field exists and returns the result.inthashCode()Generates a hashCode based on all fields of this Document.
-
Field Details
-
FIELD_NOT_FOUND
This Object is returned fromgetAndCheckField(String)if the field does not exist.
-
-
Method Details
-
hasField
Checks if the named field exists and returns the result.- Parameters:
fieldName- the name of the field to check- Returns:
trueif the named field exists; otherwisefalse
-
getFieldNames
Return an unmodifiable list of the field names.- Returns:
- an unmodifiable list of the field names
-
getField
Reads the named field and returns its value. If the field does not existnullis returned.A
nullresult indicates that the field does not exist or that it exists and its value is currentlynull. ThehasFieldmethod 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
nullis returned. - Throws:
RuntimeException- if the field could not be deserialized
-
equals
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.
-
hashCode
int hashCode()Generates a hashCode based on all fields of this Document. -
getAndCheckField
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_FOUNDis returned. - Throws:
RuntimeException- if the field could not be deserialized
-
foreach
For each field in this document callactionwith the field'snameandvalue. Some implementations may provide an implementation of this which performs better than the default.- Parameters:
action- called for each field in this document
-