restx.entity.EntityResponseWriterRegistryFactoryMachine Maven / Gradle / Ivy
package restx.entity;
import com.google.common.collect.ImmutableSet;
import restx.factory.*;
import restx.entity.EntityResponseWriterRegistry;
@Machine
public class EntityResponseWriterRegistryFactoryMachine extends SingleNameFactoryMachine {
public static final Name NAME = Name.of(restx.entity.EntityResponseWriterRegistry.class, "EntityResponseWriterRegistry");
public EntityResponseWriterRegistryFactoryMachine() {
super(0, new StdMachineEngine(NAME, 0, BoundlessComponentBox.FACTORY) {
private final Factory.Query entityDefaultContentTypeProviders = Factory.Query.byClass(restx.entity.EntityDefaultContentTypeProvider.class).optional();
private final Factory.Query entityResponseWriterFactories = Factory.Query.byClass(restx.entity.EntityResponseWriterFactory.class).optional();
@Override
public BillOfMaterials getBillOfMaterial() {
return new BillOfMaterials(ImmutableSet.>of(
entityDefaultContentTypeProviders,
entityResponseWriterFactories
));
}
@Override
protected restx.entity.EntityResponseWriterRegistry doNewComponent(SatisfiedBOM satisfiedBOM) {
return new EntityResponseWriterRegistry(
satisfiedBOM.getAsComponents(entityDefaultContentTypeProviders),
satisfiedBOM.getAsComponents(entityResponseWriterFactories)
);
}
});
}
}