class JsonCnd {

    public static JsonObject toJson(final @NotNull List<QNodeTypeDefinition> ntDefs,
                                    final @NotNull NamespaceMapping mapping) {
        final NamePathResolver resolver = new DefaultNamePathResolver(mapping);
        return ntDefs.stream()
                .map(def -> toEntry(def, NodeTypeDefinitionKey.writeAllJson(def, resolver)))
                .filter(testValue(JavaxJson::nonEmptyValue))
                .map(mapKey(compose1(QNodeTypeDefinition::getName, uncheck1(jcrNameOrResidual(resolver)))))
                .sorted(Map.Entry.comparingByKey())
                .collect(JsonCollectors.toJsonObject());
    }

    private  JsonCnd();

}