use of org.mongodb.morphia.annotations.Indexes in project morphia by mongodb.
the class IndexHelper method collectTopLevelIndexes.
private List<Index> collectTopLevelIndexes(final MappedClass mc) {
List<Index> list = new ArrayList<Index>();
if (mc != null) {
final List<Indexes> annotations = mc.getAnnotations(Indexes.class);
if (annotations != null) {
for (final Indexes indexes : annotations) {
for (final Index index : indexes.value()) {
Index updated = index;
if (index.fields().length == 0) {
LOG.warning(format("This index on '%s' is using deprecated configuration options. Please update to use the " + "fields value on @Index: %s", mc.getClazz().getName(), index.toString()));
updated = new IndexBuilder().migrate(index);
}
List<Field> fields = new ArrayList<Field>();
for (Field field : updated.fields()) {
fields.add(new FieldBuilder().value(findField(mc, index.options(), asList(field.value().split("\\.")))).type(field.type()).weight(field.weight()));
}
list.add(replaceFields(updated, fields));
}
}
}
list.addAll(collectTopLevelIndexes(mc.getSuperClass()));
}
return list;
}
Aggregations