samplest.hello.HelloResourceRouterFactoryMachine Maven / Gradle / Ivy
package samplest.hello;
import com.google.common.collect.ImmutableSet;
import restx.factory.*;
import samplest.hello.HelloResourceRouter;
@Machine
public class HelloResourceRouterFactoryMachine extends SingleNameFactoryMachine {
public static final Name NAME = Name.of(samplest.hello.HelloResourceRouter.class, "HelloResourceRouter");
public HelloResourceRouterFactoryMachine() {
super(0, new StdMachineEngine(NAME, 0, BoundlessComponentBox.FACTORY) {
private final Factory.Query resource = Factory.Query.byClass(samplest.hello.HelloResource.class).mandatory();
private final Factory.Query readerRegistry = Factory.Query.byClass(restx.entity.EntityRequestBodyReaderRegistry.class).mandatory();
private final Factory.Query writerRegistry = Factory.Query.byClass(restx.entity.EntityResponseWriterRegistry.class).mandatory();
private final Factory.Query converter = Factory.Query.byClass(restx.converters.MainStringConverter.class).mandatory();
private final Factory.Query pf = Factory.Query.byClass(restx.security.PermissionFactory.class).mandatory();
private final Factory.Query validator = Factory.Query.byClass(jakarta.validation.Validator.class).optional();
private final Factory.Query securityManager = Factory.Query.byClass(restx.security.RestxSecurityManager.class).mandatory();
private final Factory.Query paramMapperRegistry = Factory.Query.byClass(restx.endpoint.EndpointParameterMapperRegistry.class).mandatory();
@Override
public BillOfMaterials getBillOfMaterial() {
return new BillOfMaterials(ImmutableSet.>of(
resource,
readerRegistry,
writerRegistry,
converter,
pf,
validator,
securityManager,
paramMapperRegistry
));
}
@Override
protected samplest.hello.HelloResourceRouter doNewComponent(SatisfiedBOM satisfiedBOM) {
return new HelloResourceRouter(
satisfiedBOM.getOne(resource).get().getComponent(),
satisfiedBOM.getOne(readerRegistry).get().getComponent(),
satisfiedBOM.getOne(writerRegistry).get().getComponent(),
satisfiedBOM.getOne(converter).get().getComponent(),
satisfiedBOM.getOne(pf).get().getComponent(),
satisfiedBOM.getOneAsComponent(validator),
satisfiedBOM.getOne(securityManager).get().getComponent(),
satisfiedBOM.getOne(paramMapperRegistry).get().getComponent()
);
}
});
}
}