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<FieldDef<T,?>>
getField(FieldDef<T,?> first, FieldDef<T,?>... rest)
Look up fields in this schema.com.google.common.collect.ImmutableMap<String,FieldDef<T,?>>
getFields()
Get all fields in this schema.com.google.common.collect.ImmutableMap<String,FieldDef<T,?>>
getStoredFields()
int
getVersion()
boolean
hasField(FieldDef<T,?> field)
Check whether a field is present in this schema.void
setVersion(int version)
String
toString()
boolean
useLegacyNumericFields()
-
-
-
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...)
orhasField(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
orrest
, 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)
-
-