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 final Object
    This Object is returned from getAndCheckField(String) if the field does not exist.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object other)
    Returns true if the given object is equals to this Document.
    default void
    For each field in this document call action with the field's name and value.
    default Object
    Checks if the field exists and if it does returns its value.
    getField(String fieldName)
    Reads the named field and returns its value.
    Return an unmodifiable list of the field names.
    boolean
    hasField(String fieldName)
    Checks if the named field exists and returns the result.
    int
    Generates a hashCode based on all fields of this Document.
  • Field Details

  • Method Details

    • hasField

      boolean hasField(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; otherwise false
    • getFieldNames

      List<String> getFieldNames()
      Return an unmodifiable list of the field names.
      Returns:
      an unmodifiable list of the field names
    • getField

      Object getField(String fieldName)
      Reads the named field and returns its value. If the field does not exist null is returned.

      A null result indicates that the field does not exist or that it exists and its value is currently null. The hasField 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:
      RuntimeException - if the field could not be deserialized
    • equals

      boolean equals(Object other)
      Returns true if the given object is equals to this Document.

      Otherwise equality of two Documents is determined as follows:

      1. Every field must be equal.

      A field is equal if all the following are true:

      1. The field name is equal.
      2. The field value is equal.
      A field's value may be deserialized to determine if it is equals.
      Overrides:
      equals in class Object
      Parameters:
      other - the other Document to compare to this.
      Returns:
      true if this instance is equal to other.
    • hashCode

      int hashCode()
      Generates a hashCode based on all fields of this Document.
      Overrides:
      hashCode in class Object
    • getAndCheckField

      default Object getAndCheckField(String fieldName)
      Checks if the field exists and if it does returns its value. If the field does not exist returns FIELD_NOT_FOUND. Otherwise, behaves the same as getField(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:
      RuntimeException - if the field could not be deserialized
    • foreach

      default void foreach(BiConsumer<String,Object> action)
      For each field in this document call action with the field's name and value. Some implementations may provide an implementation of this which performs better than the default.
      Parameters:
      action - called for each field in this document