samplest.hello.primitive.PrimitiveResourceFactoryMachine Maven / Gradle / Ivy
package samplest.hello.primitive;
import com.google.common.collect.ImmutableSet;
import restx.factory.*;
import samplest.hello.primitive.PrimitiveResource;
@Machine
public class PrimitiveResourceFactoryMachine extends SingleNameFactoryMachine {
public static final Name NAME = Name.of(samplest.hello.primitive.PrimitiveResource.class, "PrimitiveResource");
public PrimitiveResourceFactoryMachine() {
super(0, new StdMachineEngine(NAME, 0, BoundlessComponentBox.FACTORY) {
private final Factory.Query anInt = Factory.Query.byName(Name.of(java.lang.Integer.class, "int")).mandatory();
private final Factory.Query anIntWhen = Factory.Query.byName(Name.of(java.lang.Integer.class, "intWhen")).mandatory();
private final Factory.Query anIntAlternativeWhen = Factory.Query.byName(Name.of(java.lang.Integer.class, "intAlternativeWhen")).mandatory();
@Override
public BillOfMaterials getBillOfMaterial() {
return new BillOfMaterials(ImmutableSet.>of(
anInt,
anIntWhen,
anIntAlternativeWhen
));
}
@Override
protected samplest.hello.primitive.PrimitiveResource doNewComponent(SatisfiedBOM satisfiedBOM) {
return new PrimitiveResource(
satisfiedBOM.getOne(anInt).get().getComponent(),
satisfiedBOM.getOne(anIntWhen).get().getComponent(),
satisfiedBOM.getOne(anIntAlternativeWhen).get().getComponent()
);
}
});
}
}