use of org.whole.lang.models.model.FeatureModifiers in project whole by wholeplatform.
the class ControlQueriesTest method testQueryDecl8.
@Test
public void testQueryDecl8() {
ModelsEntityFactory mef = ModelsEntityFactory.instance;
FeatureModifiers modifiers = mef.createFeatureModifiers(mef.createFeatureModifier(FeatureModifierEnum.optional), mef.createFeatureModifier(FeatureModifierEnum.derived), mef.createFeatureModifier(FeatureModifierEnum.id));
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("queryDecl8");
int count = 0;
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, modifiers)) {
IEntity modifier = modifiers.wGet(count++);
assertTrue(Matcher.match(modifier, p));
}
assertEquals(modifiers.wSize(), count);
}
use of org.whole.lang.models.model.FeatureModifiers in project whole by wholeplatform.
the class ModelsJavaModelGeneratorVisitor method visit.
public void visit(Feature feature) {
String name = feature.getName().wStringValue();
// was StringUtils.javaKeywordFilter(name);
String fName = modelInfo.featureImplName(name);
String type = feature.getType().wStringValue();
String fType = modelInfo.entityImplName(type);
String fQType = modelsGen.entityInterfaceQName(fType);
String oName = null;
String ofName = null;
SimpleName oppositeName = feature.getOppositeName();
if (DataTypeUtils.getDataKind(oppositeName).isString()) {
oName = oppositeName.getValue();
// was StringUtils.javaKeywordFilter(oName);
ofName = modelInfo.featureImplName(oName);
}
FeatureModifiers mods = feature.getModifiers();
featureModifiers.clear();
mods.accept(this);
boolean isByReference = mods.wContainsValue(FeatureModifierEnum.reference);
if (isConcrete)
simpleEntityBuilder.addField(fType, fName, name, mods.wContainsValue(FeatureModifierEnum.id), mods.wContainsValue(FeatureModifierEnum.optional), isByReference, mods.wContainsValue(FeatureModifierEnum.shared), mods.wContainsValue(FeatureModifierEnum.derived));
if (modelInfo.isNotInherited(metaName, name))
simpleEntityInterfaceBuilder.addField(fType, fName, name);
modelsGen.modelContextBuilder().addFeature(fType, fName);
modelsGen.visitorsBuilder().addFeature(entityName, fType, fName, name, isByReference);
modelsGen.entityDescriptorEnumBuilder().addFeature(qEntityName, fType, fName, ofName, featureModifiers);
modelsGen.featureDescriptorEnumBuilder().addFeature(fType, fName, name);
if (oName != null)
modelsGen.featureDescriptorEnumBuilder().addFeature(entityName, ofName, oName);
if (isConcrete)
modelsGen.entityFactoryBuilder().addFactoryMethodCase(fQType, fName);
entityAdapterBuilder.addFeature(fType, fName, name);
}
Aggregations