samplest.hello.primitive.PrimitiveResourceRouterFactoryMachine Maven / Gradle / Ivy
package samplest.hello.primitive;
import com.google.common.collect.ImmutableSet;
import restx.factory.*;
import samplest.hello.primitive.PrimitiveResourceRouter;
@Machine
public class PrimitiveResourceRouterFactoryMachine extends SingleNameFactoryMachine {
public static final Name NAME = Name.of(samplest.hello.primitive.PrimitiveResourceRouter.class, "PrimitiveResourceRouter");
public PrimitiveResourceRouterFactoryMachine() {
super(0, new StdMachineEngine(NAME, 0, BoundlessComponentBox.FACTORY) {
private final Factory.Query resource = Factory.Query.byClass(samplest.hello.primitive.PrimitiveResource.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.primitive.PrimitiveResourceRouter doNewComponent(SatisfiedBOM satisfiedBOM) {
return new PrimitiveResourceRouter(
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()
);
}
});
}
}