2 * Copyright (c) 2016 Cisco Systems, Inc. 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 com.google.common.annotations.Beta;
11 import com.google.common.base.Preconditions;
12 import javax.annotation.Nonnull;
15 * Enumeration of supported YANG versions.
17 * @author Robert Varga
20 public enum YangVersion {
22 * Version 1, as defined in RFC6020.
24 VERSION_1("1", "RFC6020"),
26 * Version 1.1, as defined in RFC7950.
28 VERSION_1_1("1.1", "RFC7950");
30 private final String str;
31 private String reference;
33 private YangVersion(final String str, final String reference) {
34 this.str = Preconditions.checkNotNull(str);
35 this.reference = Preconditions.checkNotNull(reference);
39 * Parse a YANG version from its textual representation.
41 * @param str String to parse
42 * @return YANG version
43 * @throws IllegalArgumentException if the string is malformed
44 * @throws NullPointerException if the string is null
46 public static YangVersion parse(@Nonnull final String str) {
53 throw new IllegalArgumentException("Invalid YANG version '" + str + "'");
58 * Return the normative reference defining this YANG version.
60 * @return Normative reference.
62 @Nonnull public String getReference() {
67 * Return the canonical string represetation of this YANG version.
68 * @return Canonical string
70 @Nonnull public String toCanonicalString() {