use of org.whole.lang.commons.model.Variable in project whole by wholeplatform.
the class Matcher method removeVars.
public static boolean removeVars(IEntity pattern, boolean force) {
boolean allVarsAreOptional = true;
AbstractPatternFilterIterator<IEntity> variableIterator = IteratorFactory.descendantOrSelfMatcherIterator().withPattern(GenericMatcherFactory.instance.isVariableMatcher());
variableIterator.reset(pattern);
for (IEntity variableAdapter : variableIterator) {
Variable variable = (Variable) variableAdapter.wGetAdaptee(false);
boolean isOptional = variable.getQuantifier().getValue().isOptional();
allVarsAreOptional &= isOptional;
if (force || isOptional)
variableIterator.remove();
}
return allVarsAreOptional;
}
use of org.whole.lang.commons.model.Variable in project whole by wholeplatform.
the class InlineVariablePart method getModelSpecificChildren.
protected List<IEntity> getModelSpecificChildren() {
Variable entity = getModelEntity();
List<IEntity> children = new ArrayList<IEntity>(3);
children.add(entity.getVarType());
children.add(entity.getVarName());
children.add(entity.getQuantifier());
return children;
}
use of org.whole.lang.commons.model.Variable in project whole by wholeplatform.
the class VariablePart method getModelSpecificChildren.
protected List<IEntity> getModelSpecificChildren() {
Variable entity = getModelEntity();
List<IEntity> children = new ArrayList<IEntity>(3);
children.add(entity.getVarType());
children.add(entity.getVarName());
children.add(entity.getQuantifier());
return children;
}
use of org.whole.lang.commons.model.Variable in project whole by wholeplatform.
the class MatcherTest method testMultipleRename.
@Test
public void testMultipleRename() {
Model modelPattern = new ModelPattern().create();
Variable var1 = (Variable) modelPattern.getDeclarations().wGet(0).wGet(ModelsFeatureDescriptorEnum.features).wGet(0).wGet(ModelsFeatureDescriptorEnum.type).wGetAdaptee(false);
Variable var2 = (Variable) modelPattern.getDeclarations().wGet(1).wGet(ModelsFeatureDescriptorEnum.name).wGetAdaptee(false);
assertEquals("dataEntity", var1.getVarName().getValue());
assertEquals("dataEntity", var2.getVarName().getValue());
Matcher.rename(modelPattern, "dataEntity", "DE", false);
assertEquals("DE", var1.getVarName().getValue());
assertEquals("DE", var2.getVarName().getValue());
}
use of org.whole.lang.commons.model.Variable in project whole by wholeplatform.
the class MatcherTest method testRenameMap.
@Test
public void testRenameMap() {
Feature featurePattern = new FeaturePattern().create();
Variable var1 = (Variable) featurePattern.getType().wGetAdaptee(false);
Variable var2 = (Variable) featurePattern.getName().wGetAdaptee(false);
assertEquals("featureType", var1.getVarName().getValue());
assertEquals("featureName", var2.getVarName().getValue());
Map<String, String> map = new HashMap<String, String>();
map.put("featureType", "fType");
map.put("featureName", "fName");
Matcher.rename(featurePattern, map, false);
assertEquals("fType", var1.getVarName().getValue());
assertEquals("fName", var2.getVarName().getValue());
}
Aggregations