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 com.google.common.collect.Maps;
13 import java.util.Arrays;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
19 * Enumeration of {@code error-severity} values, as defined by
20 * <a href="https://datatracker.ietf.org/doc/html/rfc4741#section-4.3">RFC4741, section 4.3</a>.
23 public enum ErrorSeverity {
25 * An error preventing an operation from completing successfully.
29 * A warning not affecting an operation's ability to complete successfully.
33 private static final Map<String, ErrorSeverity> BY_ELEMENT_BODY =
34 Maps.uniqueIndex(Arrays.asList(values()), ErrorSeverity::elementBody);
36 private final String elementBody;
38 ErrorSeverity(final String elementName) {
39 this.elementBody = requireNonNull(elementName);
43 * Return the XML element body of this object.
45 * @return element body of this object
47 public String elementBody() {
51 public static @Nullable ErrorSeverity forElementBody(final String elementBody) {
52 return BY_ELEMENT_BODY.get(requireNonNull(elementBody));