use of io.vertigo.dynamo.domain.metamodel.DomainBuilder in project vertigo by KleeGroup.
the class DomainDynamicRegistry method createDomain.
private static Domain createDomain(final DefinitionSpace definitionSpace, final DslDefinition xdomain) {
final String domainName = xdomain.getName();
final List<String> constraintNames = xdomain.getDefinitionLinkNames("constraint");
final String type = xdomain.getDefinitionLinkName("dataType");
final Boolean multiple = (Boolean) xdomain.getPropertyValue(KspProperty.MULTIPLE);
final Properties properties = extractProperties(xdomain);
final DomainBuilder domainBuilder;
if ("DtObject".equals(type)) {
domainBuilder = Domain.builder(domainName, properties.getValue(DtProperty.TYPE), false);
} else if ("DtList".equals(type)) {
domainBuilder = Domain.builder(domainName, properties.getValue(DtProperty.TYPE), true);
} else {
final DataType dataType = DataType.valueOf(type);
domainBuilder = Domain.builder(domainName, dataType, multiple == null ? false : multiple);
// only primitive can have a formatter
final boolean hasFormatter = !xdomain.getDefinitionLinkNames("formatter").isEmpty();
if (hasFormatter) {
final String formatterName = xdomain.getDefinitionLinkName("formatter");
final FormatterDefinition formatterDefinition = definitionSpace.resolve(formatterName, FormatterDefinition.class);
// ---
domainBuilder.withFormatter(formatterDefinition);
}
}
return domainBuilder.withConstraints(createConstraints(definitionSpace, constraintNames)).withProperties(properties).build();
}
Aggregations