2 * Copyright (c) 2020 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 org.eclipse.jdt.annotation.NonNullByDefault;
13 * Item ordering, as specified by <a href="https://tools.ietf.org/html/rfc7950#section-7.7.1">RFC7950 section 7.7.1</a>.
16 public enum Ordering {
18 * The equivalent of {@code ordered-by system}.
22 * The equivalent of {@code ordered-by user}.
26 private String argumentString;
28 Ordering(final String argumentString) {
29 this.argumentString = argumentString;
33 * Return the {code ordered-by} string argument this Ordering represents.
35 * @return Argument string
37 public String argument() {
38 return argumentString;
42 * Return the Ordering corresponding to an argument string.
44 * @param argumentString Argument string
45 * @return Corresponding Ordering
46 * @throws NullPointerException if {code argumentString} is null
47 * @throws IllegalArgumentException if the argument string is not a valid Ordering
49 public static Ordering forArgument(final String argumentString) {
50 switch (argumentString) {
56 throw new IllegalArgumentException("Invalid ordering string '" + argumentString + "'");