VMware GemFire Java API Reference
Package org.apache.geode.cache
Interface Document
-
- All Known Subinterfaces:
JsonDocument,PdxInstance,WritablePdxInstance
public interface DocumentUsers 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.ObjectFIELD_NOT_FOUNDThis 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 booleanequals(java.lang.Object other)Returns true if the given object is equals to this Document.default voidforeach(java.util.function.BiConsumer<java.lang.String,java.lang.Object> action)For each field in this document callactionwith the field'snameandvalue.default java.lang.ObjectgetAndCheckField(java.lang.String fieldName)Checks if the field exists and if it does returns its value.java.lang.ObjectgetField(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.booleanhasField(java.lang.String fieldName)Checks if the named field exists and returns the result.inthashCode()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:
trueif 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 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:
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:
equalsin classjava.lang.Object- Parameters:
other- the other Document to compare to this.- Returns:
trueif this instance is equal toother.
-
hashCode
int hashCode()
Generates a hashCode based on all fields of this Document.- Overrides:
hashCodein 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_FOUNDis 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 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
-
-