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");
}
Aggregations