private static Action fromElement()

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


        private static Action fromElement(final Element element) {

            // Read `issue`
            @Nullable String issue = trimNullable(element.getAttribute("issue"));
            final String issuePattern = "^LOG4J2-[0-9]+$";
            if (isBlank(issue)) {
                issue = null;
            } else if (!issue.matches(issuePattern)) {
                throw XmlReader.failureAtXmlNode(
                        element, "`issue` doesn't match with the `%s` pattern: `%s`", issuePattern, issue);
            }

            // Read `type`
            @Nullable final String typeString = trimNullable(element.getAttribute("type"));
            final Type type;
            if (isBlank(typeString)) {
                type = Type.UPDATE;
            } else {
                try {
                    type = Type.valueOf(typeString.toUpperCase(Locale.US));
                } catch (IllegalArgumentException error) {
                    throw failureAtXmlNode(error, element, "invalid type: `%s`", typeString);
                }
            }

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

            // Read `dueTo`
            @Nullable String dueTo = trimNullable(element.getAttribute("due-to"));
            if (isBlank(dueTo)) {
                dueTo = null;
            }

            // Read `description`
            @Nullable final String description = trimNullable(element.getTextContent());
            if (isBlank(description)) {
                throw XmlReader.failureAtXmlNode(element, "blank `description`");
            }

            // Create the instance
            return new Action(issue, type, dev, dueTo, description);
        }