@Test void testNonObjectNamespaceFile() { final URL res = FileNamespaceService.class.getResource("/invalidNamespaces.json"); assertTrue(FileNamespaceService.read(res.getPath()).isEmpty()); }
static Map<String, String> read(final String filePath) { final File file = new File(filePath); final Map<String, String> namespaces = new ConcurrentHashMap<>(); if (file.exists()) { try { Optional.ofNullable(MAPPER.readTree(new File(filePath))) .filter(JsonNode::isObject).map(JsonNode::fields).ifPresent(fields -> fields.forEachRemaining(node -> { final JsonNode value = node.getValue(); if (value.isTextual()) { namespaces.put(node.getKey(), value.textValue()); } })); } catch (final IOException ex) { throw new UncheckedIOException(ex); } } return namespaces; }
FileNamespaceService implements NamespaceService { static Map<String, String> read(final String filePath) { final File file = new File(filePath); final Map<String, String> namespaces = new ConcurrentHashMap<>(); if (file.exists()) { try { Optional.ofNullable(MAPPER.readTree(new File(filePath))) .filter(JsonNode::isObject).map(JsonNode::fields).ifPresent(fields -> fields.forEachRemaining(node -> { final JsonNode value = node.getValue(); if (value.isTextual()) { namespaces.put(node.getKey(), value.textValue()); } })); } catch (final IOException ex) { throw new UncheckedIOException(ex); } } return namespaces; } }
FileNamespaceService implements NamespaceService { static Map<String, String> read(final String filePath) { final File file = new File(filePath); final Map<String, String> namespaces = new ConcurrentHashMap<>(); if (file.exists()) { try { Optional.ofNullable(MAPPER.readTree(new File(filePath))) .filter(JsonNode::isObject).map(JsonNode::fields).ifPresent(fields -> fields.forEachRemaining(node -> { final JsonNode value = node.getValue(); if (value.isTextual()) { namespaces.put(node.getKey(), value.textValue()); } })); } catch (final IOException ex) { throw new UncheckedIOException(ex); } } return namespaces; } FileNamespaceService();  FileNamespaceService(final String path); }
FileNamespaceService implements NamespaceService { static Map<String, String> read(final String filePath) { final File file = new File(filePath); final Map<String, String> namespaces = new ConcurrentHashMap<>(); if (file.exists()) { try { Optional.ofNullable(MAPPER.readTree(new File(filePath))) .filter(JsonNode::isObject).map(JsonNode::fields).ifPresent(fields -> fields.forEachRemaining(node -> { final JsonNode value = node.getValue(); if (value.isTextual()) { namespaces.put(node.getKey(), value.textValue()); } })); } catch (final IOException ex) { throw new UncheckedIOException(ex); } } return namespaces; } FileNamespaceService();  FileNamespaceService(final String path); @Override Map<String, String> getNamespaces(); @Override boolean setPrefix(final String prefix, final String namespace); }
FileNamespaceService implements NamespaceService { static Map<String, String> read(final String filePath) { final File file = new File(filePath); final Map<String, String> namespaces = new ConcurrentHashMap<>(); if (file.exists()) { try { Optional.ofNullable(MAPPER.readTree(new File(filePath))) .filter(JsonNode::isObject).map(JsonNode::fields).ifPresent(fields -> fields.forEachRemaining(node -> { final JsonNode value = node.getValue(); if (value.isTextual()) { namespaces.put(node.getKey(), value.textValue()); } })); } catch (final IOException ex) { throw new UncheckedIOException(ex); } } return namespaces; } FileNamespaceService();  FileNamespaceService(final String path); @Override Map<String, String> getNamespaces(); @Override boolean setPrefix(final String prefix, final String namespace); static final String CONFIG_FILE_NAMESPACE_PATH; }