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.
    • 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 call action with the field's name and value.
      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.
    • 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; otherwise false
      • 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 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:
        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:

        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 java.lang.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 java.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 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:
        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 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