use of io.vertigo.dynamo.plugins.environment.dsl.entity.DslEntityField in project vertigo by KleeGroup.
the class DslDefinitionBodyRule method createMainRule.
private static PegRule<List<Object>> createMainRule(final DslEntity entity) {
Assertion.checkNotNull(entity);
final List<String> attributeNames = new ArrayList<>();
final List<PegRule<?>> innerDefinitionRules = new ArrayList<>();
for (final DslEntityField dslEntityField : entity.getFields()) {
attributeNames.add(dslEntityField.getName());
final DslEntity dslEntity;
if (dslEntityField.getType() instanceof DslEntity) {
dslEntity = DslEntity.class.cast(dslEntityField.getType());
} else if (dslEntityField.getType() instanceof DslEntityLink) {
dslEntity = DslEntityLink.class.cast(dslEntityField.getType()).getEntity();
} else {
// case property
dslEntity = null;
}
if (dslEntity != null) {
innerDefinitionRules.add(new DslInnerDefinitionRule(dslEntityField.getName(), dslEntity));
}
}
final DslPropertyDeclarationRule propertyDeclarationRule = new DslPropertyDeclarationRule(entity.getPropertyNames());
final DslDefinitionEntryRule xDefinitionEntryRule = new DslDefinitionEntryRule(attributeNames);
final PegRule<PegChoice> firstOfRule = PegRules.choice(// 0
propertyDeclarationRule, // 1
xDefinitionEntryRule, // 2,
PegRules.choice(innerDefinitionRules), SPACES);
final PegRule<List<PegChoice>> manyRule = PegRules.zeroOrMore(firstOfRule, false);
return PegRules.sequence(OBJECT_START, SPACES, // 2
manyRule, SPACES, OBJECT_END);
}
use of io.vertigo.dynamo.plugins.environment.dsl.entity.DslEntityField in project vertigo by KleeGroup.
the class DslDefinitionBuilder method addPropertyValue.
/**
* @param fieldName Name of the field
* @param value Valeur de la propriété
* @return this builder
*/
public DslDefinitionBuilder addPropertyValue(final String fieldName, final Object value) {
final DslEntityField dslEntityField = entity.getField(fieldName);
Assertion.checkState(dslEntityField.getType().isProperty(), "expected a property on {0}", fieldName);
// ----
entity.getPropertyType(fieldName).checkValue(value);
propertyValueByFieldName.put(dslEntityField, value);
return this;
}
Aggregations