public static void toJSON(OutputWriter outputWriter, ArtifactStore store) {
outputWriter
.addLinks(linksWriter -> linksWriter
.addLink("self", Routes.ArtifactStoreConfig.id(store.getId()))
.addAbsoluteLink("doc", Routes.ArtifactStoreConfig.DOC)
.addLink("find", Routes.ArtifactStoreConfig.find()))
.add("id", store.getId())
.add("plugin_id", store.getPluginId())
.addChildList("properties", listWriter ->
store.forEach(property ->
listWriter.addChild(propertyWriter ->
ConfigurationPropertyRepresenter.toJSON(propertyWriter, property))));
if (store.hasErrors()) {
Map<String, String> fieldMapping = Collections.singletonMap("pluginId", "plugin_id");
outputWriter.addChild("errors", errorWriter -> new ErrorGetter(fieldMapping).toJSON(errorWriter, store));
}
}