2 * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.common;
10 import static java.util.Objects.requireNonNull;
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.eclipse.jdt.annotation.Nullable;
16 * Enumeration of {@code error-severity} values, as defined by
17 * <a href="https://www.rfc-editor.org/rfc/rfc4741#section-4.3">RFC4741, section 4.3</a>.
20 public enum ErrorSeverity {
22 * An error preventing an operation from completing successfully.
26 * A warning not affecting an operation's ability to complete successfully.
30 private final String elementBody;
32 ErrorSeverity(final String elementBody) {
33 this.elementBody = requireNonNull(elementBody);
37 * Return the XML element body of this object.
39 * @return element body of this object
41 public String elementBody() {
45 public static @Nullable ErrorSeverity forElementBody(final String elementBody) {
46 return switch (elementBody) {
47 case "error" -> ERROR;
48 case "warning" -> WARNING;