Search in sources :

Example 1 with ABSDynamicProduct

use of org.abs_models.backend.java.lib.runtime.ABSDynamicProduct in project abstools by abstools.

the class Product method setupMetaAPI.

/*
     * Define the methods of this class
     */
public static void setupMetaAPI() {
    thisClass.setName("Product");
    /*
         * MetaABS Product API -- cf. abslang.abs module ABS.Meta
         */
    thisClass.addMethod(/*ABSString*/
    "getName", new ABSClosure() {

        @Override
        public ABSString exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct thisP = (ABSDynamicProduct) t;
            return ABSString.fromString(thisP.getName());
        }
    });
    thisClass.addMethod(/*List<ABSDynamicFeature>*/
    "getFeatures", new ABSClosure() {

        @Override
        public ABSValue exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct thisP = (ABSDynamicProduct) t;
            ArrayList<ABSDynamicFeature> features = new ArrayList<>();
            for (ABSDynamicFeature f : thisP.getFeatures()) {
                features.add(f);
            }
            return ListUtils.toABSList(features);
        }
    });
    thisClass.addMethod(/*Set<ABSDynamicProduct>*/
    "getConfigurableProducts", new ABSClosure() {

        @Override
        public ABSValue exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct thisP = (ABSDynamicProduct) t;
            return ListUtils.toABSSet(thisP.getConfigurableProducts());
        }
    });
    thisClass.addMethod(/*ABSDynamicReconfiguration*/
    "getReconfiguration", new ABSClosure() {

        @Override
        public ABSDynamicReconfiguration exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct thisP = (ABSDynamicProduct) t;
            ABSDynamicProduct targetP = (ABSDynamicProduct) params[0];
            return thisP.getReconfiguration(targetP);
        }
    });
}
Also used : ABSDynamicObject(org.abs_models.backend.java.lib.runtime.ABSDynamicObject) ABSClosure(org.abs_models.backend.java.lib.runtime.ABSClosure) ABSDynamicFeature(org.abs_models.backend.java.lib.runtime.ABSDynamicFeature) ABSDynamicProduct(org.abs_models.backend.java.lib.runtime.ABSDynamicProduct) ArrayList(java.util.ArrayList) ABSValue(org.abs_models.backend.java.lib.types.ABSValue) ABSString(org.abs_models.backend.java.lib.types.ABSString) ABSDynamicReconfiguration(org.abs_models.backend.java.lib.runtime.ABSDynamicReconfiguration)

Example 2 with ABSDynamicProduct

use of org.abs_models.backend.java.lib.runtime.ABSDynamicProduct in project abstools by abstools.

the class Reconfiguration method setupMetaAPI.

/*
     * Define the methods of this class
     */
public static void setupMetaAPI() {
    thisClass.setName("Reconfiguration");
    /* 
         * MetaABS Reconfiguration API -- cf. abslang.abs module ABS.Meta 
         */
    thisClass.addMethod(/*ABSString*/
    "getName", new ABSClosure() {

        @Override
        public ABSString exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
            return ABSString.fromString(thisR.getName());
        }
    });
    thisClass.addMethod(/*ABSDynamicProduct*/
    "getCurrentProduct", new ABSClosure() {

        @Override
        public ABSDynamicProduct exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
            return thisR.getCurrentProduct();
        }
    });
    thisClass.addMethod(/*ABSUnit*/
    "setCurrentProduct", new ABSClosure() {

        @Override
        public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
            ABSDynamicProduct prod = (ABSDynamicProduct) params[0];
            thisR.setCurrentProduct(prod);
            return ABSUnit.UNIT;
        }
    });
    thisClass.addMethod(/*ABSDynamicProduct*/
    "getTargetProduct", new ABSClosure() {

        @Override
        public ABSDynamicProduct exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
            return thisR.getTargetProduct();
        }
    });
    thisClass.addMethod(/*ABSUnit*/
    "setTargetProduct", new ABSClosure() {

        @Override
        public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
            ABSDynamicProduct prod = (ABSDynamicProduct) params[0];
            thisR.setTargetProduct(prod);
            return ABSUnit.UNIT;
        }
    });
    thisClass.addMethod(/*List<ABSDynamicDelta>*/
    "getDeltas", new ABSClosure() {

        @Override
        public ABSValue exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
            List<ABSDynamicDelta> deltas = thisR.getDeltas();
            return ListUtils.toABSList(deltas);
        }
    });
    thisClass.addMethod(/*List<ABSDynamicDelta>*/
    "setDeltas", new ABSClosure() {

        @Override
        public ABSValue exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
            // TODO
            return ABSUnit.UNIT;
        }
    });
    thisClass.addMethod(/*ABSDynamicUpdate*/
    "getStateUpdate", new ABSClosure() {

        @Override
        public ABSDynamicUpdate exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
            return thisR.getUpdate();
        }
    });
    thisClass.addMethod(/*List<ABSDynamicDelta>*/
    "setStateUpdate", new ABSClosure() {

        @Override
        public ABSValue exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
            ABSDynamicUpdate upd = (ABSDynamicUpdate) params[0];
            thisR.setUpdate(upd);
            return ABSUnit.UNIT;
        }
    });
}
Also used : ABSDynamicObject(org.abs_models.backend.java.lib.runtime.ABSDynamicObject) ABSClosure(org.abs_models.backend.java.lib.runtime.ABSClosure) ABSDynamicProduct(org.abs_models.backend.java.lib.runtime.ABSDynamicProduct) ABSUnit(org.abs_models.backend.java.lib.types.ABSUnit) List(java.util.List) ABSDynamicUpdate(org.abs_models.backend.java.lib.runtime.ABSDynamicUpdate) ABSValue(org.abs_models.backend.java.lib.types.ABSValue) ABSString(org.abs_models.backend.java.lib.types.ABSString) ABSDynamicReconfiguration(org.abs_models.backend.java.lib.runtime.ABSDynamicReconfiguration)

Example 3 with ABSDynamicProduct

use of org.abs_models.backend.java.lib.runtime.ABSDynamicProduct in project abstools by abstools.

the class ProductLine method setupAPI.

private static void setupAPI() {
    thisClass.setName("ProductLine");
    /* 
         * MetaABS ProductLine API -- cf. abslang.abs module ABS.Meta 
         */
    thisClass.addMethod(/*ABSDynamicProduct*/
    "getCurrentProduct", new ABSClosure() {

        @Override
        public ABSDynamicProduct exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct currentProd = t.__ABS_getRuntime().getDSPL().getCurrentProduct();
            return currentProd;
        }
    });
    thisClass.addMethod(/*ABSDynamicProduct*/
    "getProduct", new ABSClosure() {

        @Override
        public ABSDynamicProduct exec(ABSDynamicObject t, ABSValue... params) {
            ABSString name = (ABSString) params[0];
            ABSDynamicProduct product = t.__ABS_getRuntime().getDSPL().getProduct(name.getString());
            return product;
        }
    });
    thisClass.addMethod(/*ABSUnit*/
    "reconfigure", new ABSClosure() {

        @Override
        public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct targetProd = (ABSDynamicProduct) params[0];
            ABSDynamicProductLine pl = t.__ABS_getRuntime().getDSPL();
            pl.reconfigure(targetProd);
            return ABSUnit.UNIT;
        }
    });
    thisClass.addMethod(/*ABSUnit*/
    "addProduct", new ABSClosure() {

        @Override
        public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct product = (ABSDynamicProduct) params[0];
            t.__ABS_getRuntime().getDSPL().addProduct(product);
            return ABSUnit.UNIT;
        }
    });
    thisClass.addMethod(/*ABSUnit*/
    "removeProduct", new ABSClosure() {

        @Override
        public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct product = (ABSDynamicProduct) params[0];
            t.__ABS_getRuntime().getDSPL().removeProduct(product);
            return ABSUnit.UNIT;
        }
    });
    thisClass.addMethod(/*ABSUnit*/
    "addReconfiguration", new ABSClosure() {

        @Override
        public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicReconfiguration recf = (ABSDynamicReconfiguration) params[0];
            t.__ABS_getRuntime().getDSPL().addReconfiguration(recf);
            return ABSUnit.UNIT;
        }
    });
    thisClass.addMethod(/*ABSUnit*/
    "removeReconfiguration", new ABSClosure() {

        @Override
        public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicReconfiguration recf = (ABSDynamicReconfiguration) params[0];
            t.__ABS_getRuntime().getDSPL().removeReconfiguration(recf);
            return ABSUnit.UNIT;
        }
    });
}
Also used : ABSDynamicObject(org.abs_models.backend.java.lib.runtime.ABSDynamicObject) ABSClosure(org.abs_models.backend.java.lib.runtime.ABSClosure) ABSDynamicProductLine(org.abs_models.backend.java.lib.runtime.ABSDynamicProductLine) ABSDynamicProduct(org.abs_models.backend.java.lib.runtime.ABSDynamicProduct) ABSUnit(org.abs_models.backend.java.lib.types.ABSUnit) ABSValue(org.abs_models.backend.java.lib.types.ABSValue) ABSString(org.abs_models.backend.java.lib.types.ABSString) ABSDynamicReconfiguration(org.abs_models.backend.java.lib.runtime.ABSDynamicReconfiguration)

Aggregations

ABSClosure (org.abs_models.backend.java.lib.runtime.ABSClosure)3 ABSDynamicObject (org.abs_models.backend.java.lib.runtime.ABSDynamicObject)3 ABSDynamicProduct (org.abs_models.backend.java.lib.runtime.ABSDynamicProduct)3 ABSDynamicReconfiguration (org.abs_models.backend.java.lib.runtime.ABSDynamicReconfiguration)3 ABSString (org.abs_models.backend.java.lib.types.ABSString)3 ABSValue (org.abs_models.backend.java.lib.types.ABSValue)3 ABSUnit (org.abs_models.backend.java.lib.types.ABSUnit)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ABSDynamicFeature (org.abs_models.backend.java.lib.runtime.ABSDynamicFeature)1 ABSDynamicProductLine (org.abs_models.backend.java.lib.runtime.ABSDynamicProductLine)1 ABSDynamicUpdate (org.abs_models.backend.java.lib.runtime.ABSDynamicUpdate)1