use of io.crnk.core.utils.Supplier in project crnk-framework by crnk-project.
the class MetaResourceRepositoryTest method setup.
@Before
public void setup() {
super.setup();
ResourceMetaProvider provider = new ResourceMetaProvider();
lookup = new MetaLookup();
lookup.setModuleContext(boot.getModuleRegistry().getContext());
lookup.addProvider(provider);
lookup.initialize();
repo = new MetaResourceRepositoryImpl(new Supplier<MetaLookup>() {
@Override
public MetaLookup get() {
return lookup;
}
}, MetaElement.class);
}
use of io.crnk.core.utils.Supplier in project crnk-framework by crnk-project.
the class MetaModule method registerRepositories.
protected void registerRepositories(DefaultResourceInformationProvider informationBuilder, Set<Class<? extends MetaElement>> metaClasses) {
Supplier<MetaLookup> lookupSupplier = new Supplier<MetaLookup>() {
@Override
public MetaLookup get() {
return getLookup();
}
};
for (Class<? extends MetaElement> metaClass : metaClasses) {
context.addRepository(new MetaResourceRepositoryImpl<>(lookupSupplier, metaClass));
HashSet<Class<? extends MetaElement>> targetResourceClasses = new HashSet<>();
ResourceInformation information = informationBuilder.build(metaClass);
for (ResourceField relationshipField : information.getRelationshipFields()) {
if (!MetaElement.class.isAssignableFrom(relationshipField.getElementType())) {
throw new IllegalStateException("only MetaElement relations supported, got " + relationshipField);
}
targetResourceClasses.add((Class<? extends MetaElement>) relationshipField.getElementType());
}
for (Class<? extends MetaElement> targetResourceClass : targetResourceClasses) {
context.addRepository(new MetaRelationshipRepositoryImpl(lookupSupplier, metaClass, targetResourceClass));
}
}
}
use of io.crnk.core.utils.Supplier in project crnk-framework by crnk-project.
the class MetaRelationshipRepositoryImplTest method setup.
@Before
public void setup() {
super.setup();
resourceProvider = new ResourceMetaProvider();
lookup = new MetaLookup();
lookup.setModuleContext(boot.getModuleRegistry().getContext());
lookup.addProvider(resourceProvider);
lookup.initialize();
repo = new MetaRelationshipRepositoryImpl(new Supplier<MetaLookup>() {
@Override
public MetaLookup get() {
return lookup;
}
}, MetaElement.class, MetaElement.class);
}
Aggregations