Class Schema<T>

java.lang.Object
com.google.gerrit.index.Schema<T>

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

    • getVersion

      public final int getVersion()
    • getSchemaFields

      public final com.google.common.collect.ImmutableMap<String,SchemaFieldDefs.SchemaField<T,?>> getSchemaFields()
      Get all fields in this schema.

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

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

      public final com.google.common.collect.ImmutableMap<String,IndexedField<T,?>> getIndexFields()
    • getStoredFields

      public final com.google.common.collect.ImmutableSet<String> getStoredFields()
      Returns names of SchemaFieldDefs.SchemaField fields in this schema where SchemaFieldDefs.SchemaField.isStored() is true.
    • getField

      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(SchemaFieldDefs.SchemaField<T,?> field)
      Check whether a field is present in this schema.
      Parameters:
      field - field to look up.
      Returns:
      whether the field is present.
    • hasField

      public final boolean hasField(String fieldName)
    • getSchemaField

      public SchemaFieldDefs.SchemaField<T,?> getSchemaField(String fieldName)
    • buildFields

      public final com.google.common.collect.ImmutableList<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. If any of the fields cause a StorageException, the whole operation fails and the exception is propagated to the caller.

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

      public String toString()
      Overrides:
      toString in class Object