Class Schema<T>


  • public class Schema<T>
    extends Object
    Specific version of a secondary index schema.
    • Constructor Detail

      • Schema

        public Schema​(boolean useLegacyNumericFields,
                      Iterable<FieldDef<T,​?>> fields)
      • Schema

        public Schema​(int version,
                      boolean useLegacyNumericFields,
                      Iterable<FieldDef<T,​?>> fields)
    • Method Detail

      • getVersion

        public final int getVersion()
      • useLegacyNumericFields

        public final boolean useLegacyNumericFields()
      • getFields

        public final com.google.common.collect.ImmutableMap<String,​FieldDef<T,​?>> getFields()
        Get all fields in this schema.

        This is primarily useful for iteration. Most callers should prefer one of the helper methods getField(FieldDef, FieldDef...) or hasField(FieldDef) to looking up fields by name

        Returns:
        all fields in this schema indexed by name.
      • getStoredFields

        public final com.google.common.collect.ImmutableMap<String,​FieldDef<T,​?>> getStoredFields()
        Returns:
        all fields in this schema where FieldDef.isStored() is true.
      • getField

        @SafeVarargs
        public final Optional<FieldDef<T,​?>> getField​(FieldDef<T,​?> first,
                                                            FieldDef<T,​?>... rest)
        Look up fields in this schema.
        Parameters:
        first - the preferred field to look up.
        rest - additional fields to look up.
        Returns:
        the first field in the schema matching first or rest, in order, or absent if no field matches.
      • hasField

        public final boolean hasField​(FieldDef<T,​?> field)
        Check whether a field is present in this schema.
        Parameters:
        field - field to look up.
        Returns:
        whether the field is present.
      • buildFields

        public final Iterable<Schema.Values<T>> buildFields​(T obj,
                                                            com.google.common.collect.ImmutableSet<String> skipFields)
        Build all fields in the schema from an input object.

        Null values are omitted, as are fields which cause errors, which are logged.

        Parameters:
        obj - input object.
        skipFields - set of field names to skip when indexing the document
        Returns:
        all non-null field values from the object.
      • setVersion

        public void setVersion​(int version)