/** * Generates views based on annotations found in a repository class. If the repository class * extends org.ektorp.support.CouchDbRepositorySupport its handled type will also examined for * annotations eligible for view generation. * * @param repository * @return a Map with generated views. */ public Map<String, DesignDocument.View> generateViews(final Object repository) { final Map<String, DesignDocument.View> views = new HashMap<String, DesignDocument.View>(); final Class<?> repositoryClass = repository.getClass(); final Class<?> handledType = repository instanceof CouchDbRepositorySupport<?> ? ((CouchDbRepositorySupport<?>) repository).getHandledType() : null; createDeclaredViews(views, repositoryClass); eachMethod( repositoryClass, new Predicate<Method>() { public boolean apply(Method input) { if (hasAnnotation(input, GenerateView.class)) { generateView(views, input, handledType); } return false; } }); if (handledType != null) { views.putAll(generateViewsFromPersistentType(handledType)); } return views; }