class UiSpecService implements AutoCloseable {

    public CompletionStage<Ui> convert(final String family, final String lang, final ConfigTypeNode node,
            final T context) {
        // extract root properties
        final Collection<String> rootProperties =
                node.getProperties().stream().map(SimplePropertyDefinition::getPath).collect(toSet());
        rootProperties
                .removeIf(path -> node.getProperties().stream().anyMatch(p -> path.startsWith(p.getPath() + '.')));
        if (rootProperties.isEmpty()) {
            log.warn("No root properties for configuration node {} (family={})", node.getId(), family);
        }

        // [TCOMP-767] 0.0.7 -> 0.0.8 compat
        final Collection<SimplePropertyDefinition> props;
        final Predicate<SimplePropertyDefinition> isRootProperty;
        if (rootProperties.size() == 1 && rootProperties.iterator().next().startsWith("configuration.")) {
            final String root = rootProperties.iterator().next();
            final SimplePropertyDefinition def =
                    node.getProperties().stream().filter(prop -> prop.getPath().equals(root)).findFirst().get();
            props = node
                    .getProperties()
                    .stream()
                    .map(prop -> new SimplePropertyDefinition(def.getName() + prop.getPath().substring(root.length()),
                            prop.getName(), prop.getDisplayName(), prop.getType(), prop.getDefaultValue(),
                            prop.getValidation(), prop.getMetadata(), prop.getPlaceholder(),
                            prop.getProposalDisplayNames()))
                    .collect(toList());
            isRootProperty = p -> p.getPath().equals(def.getName());
        } else {
            props = node.getProperties();
            isRootProperty = p -> rootProperties.contains(p.getPath());
        }

        return convert(node::getDisplayName, () -> family, () -> props, node::getActions, isRootProperty, context,
                lang);
    }

    public  UiSpecService(final Client client);
    public  UiSpecService(final Client client, final Jsonb jsonb);

}