private static Release fromElement()

in log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/importer/MavenChanges.java [83:114]


        private static Release fromElement(final Element element) {

            // Read `version`
            final String version = trimNullable(element.getAttribute("version"));
            if (isBlank(version)) {
                throw XmlReader.failureAtXmlNode(element, "blank attribute: `version`");
            }

            // Read `date`
            final String date = trimNullable(element.getAttribute("date"));
            final String datePattern = "^(TBD|[0-9]{4}-[0-9]{2}-[0-9]{2})$";
            if (!date.matches(datePattern)) {
                throw XmlReader.failureAtXmlNode(element, "`date` doesn't match with the `%s` pattern: `%s`", datePattern, date);
            }

            // Read actions
            final List<Action> actions = new ArrayList<>();
            final NodeList actionNodes = element.getChildNodes();
            final int actionNodeCount = actionNodes.getLength();
            for (int actionNodeIndex = 0; actionNodeIndex < actionNodeCount; actionNodeIndex++) {
                final Node actionNode = actionNodes.item(actionNodeIndex);
                if ("action".equals(actionNode.getNodeName()) && Node.ELEMENT_NODE == actionNode.getNodeType()) {
                    Element actionElement = (Element) actionNode;
                    Action action = Action.fromElement(actionElement);
                    actions.add(action);
                }
            }

            // Create the instance
            return new Release(version, date, actions);

        }