Package com.google.gerrit.index
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Schema.Builder<T>
static class
Schema.Values<T>
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterable<Schema.Values<T>>
buildFields(T obj, com.google.common.collect.ImmutableSet<String> skipFields)
Build all fields in the schema from an input object.Optional<SchemaFieldDefs.SchemaField<T,?>>
getField(SchemaFieldDefs.SchemaField<T,?> first, SchemaFieldDefs.SchemaField<T,?>... rest)
Look up fields in this schema.com.google.common.collect.ImmutableMap<String,IndexedField<T,?>>
getIndexFields()
SchemaFieldDefs.SchemaField<T,?>
getSchemaField(String fieldName)
com.google.common.collect.ImmutableMap<String,SchemaFieldDefs.SchemaField<T,?>>
getSchemaFields()
Get all fields in this schema.com.google.common.collect.ImmutableSet<String>
getStoredFields()
Returns all fields in this schema whereFieldDef.isStored()
is true.int
getVersion()
boolean
hasField(SchemaFieldDefs.SchemaField<T,?> field)
Check whether a field is present in this schema.boolean
hasField(String fieldName)
String
toString()
-
-
-
Method Detail
-
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...)
orhasField(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 all fields in this schema whereFieldDef.isStored()
is true.
-
getField
@SafeVarargs public final Optional<SchemaFieldDefs.SchemaField<T,?>> getField(SchemaFieldDefs.SchemaField<T,?> first, SchemaFieldDefs.SchemaField<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
orrest
, 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 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.
-
-