@Test void mapNoProperties() { final Map<String, Object> props = BuilderUtils.mapPropertiesElements(null, PROPERTIES); assertEquals(props, emptyMap()); }
public static Map<String, Object> mapPropertiesElements(final Element propertiesElement, final String propertiesElementName) { if (propertiesElement == null) { return emptyMap(); } if (!Objects.equals(propertiesElement.getNodeName(), propertiesElementName)) { throw new BundleLoadException("Current node is not " + propertiesElementName + " node, it is " + propertiesElement.getNodeName()); } final List<Element> properties = getChildElements(propertiesElement, PROPERTY); return properties.stream().collect(toMap(s -> s.getAttribute(ATTRIBUTE_KEY), o -> { final String propKey = o.getAttribute(ATTRIBUTE_KEY); final NodeList childNodes = o.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { final Node child = childNodes.item(i); if (child.getNodeType() == ELEMENT_NODE) { return extractPropertyValue(propKey, (Element) child); } } throw new BundleLoadException("Property " + propKey + " does not have a value"); })); }
BuilderUtils { public static Map<String, Object> mapPropertiesElements(final Element propertiesElement, final String propertiesElementName) { if (propertiesElement == null) { return emptyMap(); } if (!Objects.equals(propertiesElement.getNodeName(), propertiesElementName)) { throw new BundleLoadException("Current node is not " + propertiesElementName + " node, it is " + propertiesElement.getNodeName()); } final List<Element> properties = getChildElements(propertiesElement, PROPERTY); return properties.stream().collect(toMap(s -> s.getAttribute(ATTRIBUTE_KEY), o -> { final String propKey = o.getAttribute(ATTRIBUTE_KEY); final NodeList childNodes = o.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { final Node child = childNodes.item(i); if (child.getNodeType() == ELEMENT_NODE) { return extractPropertyValue(propKey, (Element) child); } } throw new BundleLoadException("Property " + propKey + " does not have a value"); })); } }
BuilderUtils { public static Map<String, Object> mapPropertiesElements(final Element propertiesElement, final String propertiesElementName) { if (propertiesElement == null) { return emptyMap(); } if (!Objects.equals(propertiesElement.getNodeName(), propertiesElementName)) { throw new BundleLoadException("Current node is not " + propertiesElementName + " node, it is " + propertiesElement.getNodeName()); } final List<Element> properties = getChildElements(propertiesElement, PROPERTY); return properties.stream().collect(toMap(s -> s.getAttribute(ATTRIBUTE_KEY), o -> { final String propKey = o.getAttribute(ATTRIBUTE_KEY); final NodeList childNodes = o.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { final Node child = childNodes.item(i); if (child.getNodeType() == ELEMENT_NODE) { return extractPropertyValue(propKey, (Element) child); } } throw new BundleLoadException("Property " + propKey + " does not have a value"); })); } private  BuilderUtils(); }
BuilderUtils { public static Map<String, Object> mapPropertiesElements(final Element propertiesElement, final String propertiesElementName) { if (propertiesElement == null) { return emptyMap(); } if (!Objects.equals(propertiesElement.getNodeName(), propertiesElementName)) { throw new BundleLoadException("Current node is not " + propertiesElementName + " node, it is " + propertiesElement.getNodeName()); } final List<Element> properties = getChildElements(propertiesElement, PROPERTY); return properties.stream().collect(toMap(s -> s.getAttribute(ATTRIBUTE_KEY), o -> { final String propKey = o.getAttribute(ATTRIBUTE_KEY); final NodeList childNodes = o.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { final Node child = childNodes.item(i); if (child.getNodeType() == ELEMENT_NODE) { return extractPropertyValue(propKey, (Element) child); } } throw new BundleLoadException("Property " + propKey + " does not have a value"); })); } private  BuilderUtils(); static void buildAndAppendPropertiesElement(final Map<String, Object> properties, final Document document, final Element elementToAppendInto); static Element buildPropertiesElement(final Map<String, Object> properties, final Document document); static Element buildPropertiesElement(final Map<String, Object> properties, final Document document, final String propertiesElementName); @NotNull static Element createPropertyElement(Document document, String key, Object value); static Map<String, Object> mapPropertiesElements(final Element propertiesElement, final String propertiesElementName); static String insertPrefixToEnvironmentVariable(String environmentVariable, String prefix); static String removeAllSpecialChars(String str); }
BuilderUtils { public static Map<String, Object> mapPropertiesElements(final Element propertiesElement, final String propertiesElementName) { if (propertiesElement == null) { return emptyMap(); } if (!Objects.equals(propertiesElement.getNodeName(), propertiesElementName)) { throw new BundleLoadException("Current node is not " + propertiesElementName + " node, it is " + propertiesElement.getNodeName()); } final List<Element> properties = getChildElements(propertiesElement, PROPERTY); return properties.stream().collect(toMap(s -> s.getAttribute(ATTRIBUTE_KEY), o -> { final String propKey = o.getAttribute(ATTRIBUTE_KEY); final NodeList childNodes = o.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { final Node child = childNodes.item(i); if (child.getNodeType() == ELEMENT_NODE) { return extractPropertyValue(propKey, (Element) child); } } throw new BundleLoadException("Property " + propKey + " does not have a value"); })); } private  BuilderUtils(); static void buildAndAppendPropertiesElement(final Map<String, Object> properties, final Document document, final Element elementToAppendInto); static Element buildPropertiesElement(final Map<String, Object> properties, final Document document); static Element buildPropertiesElement(final Map<String, Object> properties, final Document document, final String propertiesElementName); @NotNull static Element createPropertyElement(Document document, String key, Object value); static Map<String, Object> mapPropertiesElements(final Element propertiesElement, final String propertiesElementName); static String insertPrefixToEnvironmentVariable(String environmentVariable, String prefix); static String removeAllSpecialChars(String str);  }