Search in sources :

Example 1 with DefaultWrapInTransformer

use of org.whole.lang.util.DefaultWrapInTransformer in project whole by wholeplatform.

the class E4Utils method wrapToBehavior.

public static IEntity wrapToBehavior(EntityDescriptor<?> ed, FeatureDescriptor intoFD, IEntityTransformer entityTransformer) {
    IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
    if (intoFD != null)
        bm.wDefValue("intoFDUri", CommonsDataTypePersistenceParser.unparseFeatureDescriptor(intoFD));
    if (entityTransformer instanceof DefaultWrapInTransformer) {
        FeatureDescriptor fd = ((DefaultWrapInTransformer) entityTransformer).getFeatureDescriptor();
        bm.wDefValue("edUri", CommonsDataTypePersistenceParser.unparseEntityDescriptor(ed));
        if (fd != null)
            bm.wDefValue("fdUri", CommonsDataTypePersistenceParser.unparseFeatureDescriptor(fd));
        else
            bm.wDefValue("fdIndex", ((DefaultWrapInTransformer) entityTransformer).getIndex());
        IEntity wrapInBehavior = WrapActionsTemplateManager.instance().create(fd != null ? "WrapIn" : "WrapInIndex");
        wrapInBehavior = BehaviorUtils.evaluate(wrapInBehavior, 1, bm);
        Matcher.removeVars(wrapInBehavior, false);
        return wrapInBehavior;
    } else if (entityTransformer instanceof DefaultWrapWithinTransformer) {
        FeatureDescriptor fd = ((DefaultWrapWithinTransformer) entityTransformer).getFeatureDescriptor();
        bm.wDefValue("edUri", CommonsDataTypePersistenceParser.unparseEntityDescriptor(ed));
        bm.wDefValue("fdUri", CommonsDataTypePersistenceParser.unparseFeatureDescriptor(fd));
        IEntity wrapWithinBehavior = WrapActionsTemplateManager.instance().create("WrapWithin");
        wrapWithinBehavior = BehaviorUtils.evaluate(wrapWithinBehavior, 1, bm);
        Matcher.removeVars(wrapWithinBehavior, false);
        return wrapWithinBehavior;
    } else
        throw new IllegalArgumentException("unsupported entity transformer");
}
Also used : DefaultWrapWithinTransformer(org.whole.lang.util.DefaultWrapWithinTransformer) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) DefaultWrapInTransformer(org.whole.lang.util.DefaultWrapInTransformer)

Aggregations

IBindingManager (org.whole.lang.bindings.IBindingManager)1 IEntity (org.whole.lang.model.IEntity)1 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)1 DefaultWrapInTransformer (org.whole.lang.util.DefaultWrapInTransformer)1 DefaultWrapWithinTransformer (org.whole.lang.util.DefaultWrapWithinTransformer)1