private Indexed getIndexedAnnotation(AnnotatedElement element) {
return element.getAnnotation(Indexed.class);
}
private Index<S> getIndex(Neo4JPersistentProperty property, GraphBacked instance) {
final Indexed indexedAnnotation = property.getAnnotation(Indexed.class);
final Class<T> type = (Class<T>) property.getOwner().getType();
final String providedIndexName = indexedAnnotation.indexName().isEmpty() ? null : indexedAnnotation.indexName();
String indexName = Indexed.Name.get(indexedAnnotation.level(), type, providedIndexName, instance.getClass());
if (!property.getIndexInfo().isFulltext()) {
return graphDatabaseContext.getIndex(type, indexName, false);
}
if (providedIndexName == null) throw new IllegalStateException("@Indexed(fullext=true) on "+property+" requires an providedIndexName too ");
String defaultIndexName = Indexed.Name.get(indexedAnnotation.level(), type, null, instance.getClass());
if (providedIndexName.equals(defaultIndexName)) throw new IllegalStateException("Full-index name for "+property+" must differ from the default name: "+defaultIndexName);
return graphDatabaseContext.getIndex(type, indexName, true);
}