io.katharsis.resource.registry.AnnotatedRepositoryEntryBuilder Maven / Gradle / Ivy
package io.katharsis.resource.registry;
import io.katharsis.locator.JsonServiceLocator;
import io.katharsis.repository.annotations.JsonApiRelationshipRepository;
import io.katharsis.repository.annotations.JsonApiResourceRepository;
import io.katharsis.repository.exception.RepositoryInstanceNotFoundException;
import io.katharsis.resource.registry.repository.AnnotatedRelationshipEntryBuilder;
import io.katharsis.resource.registry.repository.AnnotatedResourceEntryBuilder;
import io.katharsis.resource.registry.repository.RelationshipEntry;
import io.katharsis.resource.registry.repository.ResourceEntry;
import org.reflections.Reflections;
import java.lang.annotation.Annotation;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
* Repository entries builder for classes annotated with repository annotations.
*/
public class AnnotatedRepositoryEntryBuilder implements RepositoryEntryBuilder {
private final JsonServiceLocator jsonServiceLocator;
public AnnotatedRepositoryEntryBuilder(JsonServiceLocator jsonServiceLocator) {
this.jsonServiceLocator = jsonServiceLocator;
}
@Override
public ResourceEntry, ?> buildResourceRepository(Reflections reflections, Class> resourceClass) {
Predicate> classPredicate =
clazz -> resourceClass.equals(clazz.getAnnotation(JsonApiResourceRepository.class).value());
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy