All Downloads are FREE. Search and download functionalities are using the official Maven repository.

samplest.hello.primitive.PrimitiveModuleFactoryMachine Maven / Gradle / Ivy

There is a newer version: 1.2.0-rc2
Show newest version
package samplest.hello.primitive;

import com.google.common.collect.ImmutableSet;
import restx.factory.*;
import samplest.hello.primitive.PrimitiveModule;


@Machine
public class PrimitiveModuleFactoryMachine extends DefaultFactoryMachine {
    private static final PrimitiveModule module = new PrimitiveModule();

    public PrimitiveModuleFactoryMachine() {
        super(0, new MachineEngine[] {
            new StdMachineEngine(Name.of(java.lang.Integer.class, "int"), 0, BoundlessComponentBox.FACTORY) {
        
                @Override
                public BillOfMaterials getBillOfMaterial() {
                    return new BillOfMaterials(ImmutableSet.>of(
        
                    ));
                }

                @Override
                public java.lang.Integer doNewComponent(SatisfiedBOM satisfiedBOM) {
	                    return module.integer(
	        
	                    );
                }
            },
            new StdMachineEngine(Name.of(java.lang.Integer.class, "intAlternativeWhen"), 0, BoundlessComponentBox.FACTORY) {
        
                @Override
                public BillOfMaterials getBillOfMaterial() {
                    return new BillOfMaterials(ImmutableSet.>of(
        
                    ));
                }

                @Override
                public java.lang.Integer doNewComponent(SatisfiedBOM satisfiedBOM) {
	                    return module.integerAlternativeWhen(
	        
	                    );
                }
            },

            new StdMachineEngine(
                    Name.of(FactoryMachine.class, "integerWhenintWhenConditional"), 0, BoundlessComponentBox.FACTORY) {
                private Factory.Query query = Factory.Query.byName(Name.of(String.class, "restx.mode")).optional();

                @Override
                protected FactoryMachine doNewComponent(SatisfiedBOM satisfiedBOM) {
                    if (satisfiedBOM.getOne(query).isPresent()
                            && satisfiedBOM.getOne(query).get().getComponent().equals("test")) {
                        return new SingleNameFactoryMachine(0,
                                        new StdMachineEngine(
                                                Name.of(java.lang.Integer.class, "intWhen"),
                                                0, BoundlessComponentBox.FACTORY) {
                                            

                                            @Override
                                            public BillOfMaterials getBillOfMaterial() {
                                                return new BillOfMaterials(ImmutableSet.>of(
                                                    
                                                ));
                                            }

                                            @Override
                                            protected java.lang.Integer doNewComponent(SatisfiedBOM satisfiedBOM) {
                                                    return module.integerWhen(
                                                
                                                    );
                                            }
                                        });
                    } else {
                        return NoopFactoryMachine.INSTANCE;
                    }
                }

                @Override
                public BillOfMaterials getBillOfMaterial() {
                    return BillOfMaterials.of(query);
                }
            },
            new StdMachineEngine(
                    Name.of(FactoryMachine.class, "integerWhenDevintWhenConditional"), 0, BoundlessComponentBox.FACTORY) {
                private Factory.Query query = Factory.Query.byName(Name.of(String.class, "restx.mode")).optional();

                @Override
                protected FactoryMachine doNewComponent(SatisfiedBOM satisfiedBOM) {
                    if (satisfiedBOM.getOne(query).isPresent()
                            && satisfiedBOM.getOne(query).get().getComponent().equals("dev")) {
                        return new SingleNameFactoryMachine(0,
                                        new StdMachineEngine(
                                                Name.of(java.lang.Integer.class, "intWhen"),
                                                0, BoundlessComponentBox.FACTORY) {
                                            

                                            @Override
                                            public BillOfMaterials getBillOfMaterial() {
                                                return new BillOfMaterials(ImmutableSet.>of(
                                                    
                                                ));
                                            }

                                            @Override
                                            protected java.lang.Integer doNewComponent(SatisfiedBOM satisfiedBOM) {
                                                    return module.integerWhenDev(
                                                
                                                    );
                                            }
                                        });
                    } else {
                        return NoopFactoryMachine.INSTANCE;
                    }
                }

                @Override
                public BillOfMaterials getBillOfMaterial() {
                    return BillOfMaterials.of(query);
                }
            },
            new StdMachineEngine(
                    Name.of(FactoryMachine.class, "integerAlternativeWhenAltintAlternativeWhenAlternative"), 0, BoundlessComponentBox.FACTORY) {
                private Factory.Query query = Factory.Query.byName(Name.of(String.class, "restx.mode")).optional();

                @Override
                protected FactoryMachine doNewComponent(SatisfiedBOM satisfiedBOM) {
                    if (satisfiedBOM.getOne(query).isPresent()
                            && satisfiedBOM.getOne(query).get().getComponent().equals("test")) {
                        return new SingleNameFactoryMachine(-1000,
                                        new StdMachineEngine(
                                                Name.of(java.lang.Integer.class, "intAlternativeWhen"),
                                                -1000, BoundlessComponentBox.FACTORY) {
                                            

                                            @Override
                                            public BillOfMaterials getBillOfMaterial() {
                                                return new BillOfMaterials(ImmutableSet.>of(
                                                    
                                                ));
                                            }

                                            @Override
                                            protected java.lang.Integer doNewComponent(SatisfiedBOM satisfiedBOM) {
                                                    return module.integerAlternativeWhenAlt(
                                                
                                                    );
                                            }
                                        });
                    } else {
                        return NoopFactoryMachine.INSTANCE;
                    }
                }

                @Override
                public BillOfMaterials getBillOfMaterial() {
                    return BillOfMaterials.of(query);
                }
            },
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy