Search in sources :

Example 1 with Decorator

use of io.crnk.core.engine.internal.utils.Decorator in project crnk-framework by crnk-project.

the class DefaultRegistryEntryBuilder method decorateRepository.

@SuppressWarnings({ "rawtypes", "unchecked" })
public Object decorateRepository(Object repository) {
    Object decoratedRepository = repository;
    List<RepositoryDecoratorFactory> repositoryDecorators = moduleRegistry.getRepositoryDecoratorFactories();
    for (RepositoryDecoratorFactory repositoryDecorator : repositoryDecorators) {
        Decorator decorator = null;
        if (decoratedRepository instanceof RelationshipRepositoryV2) {
            decorator = repositoryDecorator.decorateRepository((RelationshipRepositoryV2) decoratedRepository);
        } else if (decoratedRepository instanceof ResourceRepositoryV2) {
            decorator = repositoryDecorator.decorateRepository((ResourceRepositoryV2) decoratedRepository);
        }
        if (decorator != null) {
            decorator.setDecoratedObject(decoratedRepository);
            decoratedRepository = decorator;
        }
    }
    return decoratedRepository;
}
Also used : Decorator(io.crnk.core.engine.internal.utils.Decorator) ResourceRepositoryV2(io.crnk.core.repository.ResourceRepositoryV2) RepositoryDecoratorFactory(io.crnk.core.repository.decorate.RepositoryDecoratorFactory) RelationshipRepositoryV2(io.crnk.core.repository.RelationshipRepositoryV2)

Aggregations

Decorator (io.crnk.core.engine.internal.utils.Decorator)1 RelationshipRepositoryV2 (io.crnk.core.repository.RelationshipRepositoryV2)1 ResourceRepositoryV2 (io.crnk.core.repository.ResourceRepositoryV2)1 RepositoryDecoratorFactory (io.crnk.core.repository.decorate.RepositoryDecoratorFactory)1