Fix OpenConfigConstants
[yangtools.git] / model / openconfig-model-api / src / main / java / org / opendaylight / yangtools / openconfig / model / api / OpenConfigConstants.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.openconfig.model.api;
9
10 import com.google.common.collect.ImmutableList;
11 import java.util.Collection;
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.opendaylight.yangtools.yang.common.QNameModule;
14 import org.opendaylight.yangtools.yang.common.Revision;
15 import org.opendaylight.yangtools.yang.common.XMLNamespace;
16 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
17 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
18
19 /**
20  * Constants associated with OpenDaylight extension in yang-ext.yang.
21  *
22  * @author Robert Varga
23  */
24 @NonNullByDefault
25 public final class OpenConfigConstants {
26     private static final String MODULE_NAME = "openconfig-extensions";
27
28     // Package-visible, because openconfig-version applies across all known revisions and needs to bind to all of them
29     static final XMLNamespace MODULE_NAMESPACE = XMLNamespace.of("http://openconfig.net/yang/openconfig-ext").intern();
30
31     // Initial revision, defining semantic-version
32     private static final Revision SEMVER_REVISION = Revision.of("2015-10-09");
33
34     // Revised extension, adds openconfig-encrypted-value
35     private static final Revision ENCRYPTED_VALUE_REVISION = Revision.of("2017-01-29");
36
37     // Revised extension, renames openconfig-encrypted-value to openconfig-hashed-value
38     private static final Revision HASHED_VALUE_REVISION = Revision.of("2017-04-11");
39
40     // Revised extension, adds extension for POSIX pattern statements
41     private static final Revision REGEXP_POSIX_REVISION = Revision.of("2020-06-16");
42
43     /**
44     * Runtime identity of model which exposed regexp-posix.
45     */
46     public static final QNameModule REGEXP_POSIX_MODULE = QNameModule.create(MODULE_NAMESPACE, REGEXP_POSIX_REVISION)
47             .intern();
48     /**
49      * Runtime identity of initial model.
50      */
51     public static final QNameModule SEMVER_MODULE = QNameModule.create(MODULE_NAMESPACE, SEMVER_REVISION).intern();
52
53     /**
54      * Runtime identity of model which exposed encrypted-value.
55      */
56     public static final QNameModule ENCRYPTED_VALUE_MODULE = QNameModule.create(MODULE_NAMESPACE,
57         ENCRYPTED_VALUE_REVISION).intern();
58
59     /**
60      * Runtime identity of model which exposed encrypted-value.
61      */
62     public static final QNameModule HASHED_VALUE_MODULE = QNameModule.create(MODULE_NAMESPACE, HASHED_VALUE_REVISION)
63             .intern();
64
65     /**
66      * Original model source name.
67      */
68     public static final SourceIdentifier SEMVER_SOURCE = RevisionSourceIdentifier.create(MODULE_NAME,
69         SEMVER_REVISION);
70
71     /**
72      * Original model source name.
73      */
74     public static final SourceIdentifier ENCRYPTED_VALUE_SOURCE = RevisionSourceIdentifier.create(MODULE_NAME,
75         ENCRYPTED_VALUE_REVISION);
76
77     /**
78      * Original model source name.
79      */
80     public static final SourceIdentifier HASHED_VALUE_SOURCE = RevisionSourceIdentifier.create(MODULE_NAME,
81         HASHED_VALUE_REVISION);
82
83     /**
84      * Original model source name.
85      */
86     public static final SourceIdentifier REGEXP_POSIX_SOURCE = RevisionSourceIdentifier.create(MODULE_NAME,
87             REGEXP_POSIX_REVISION);
88     /**
89      * Normative prefix to use when importing {@link #SEMVER_SOURCE} and later.
90      */
91     public static final String MODULE_PREFIX = "oc-ext";
92
93     private OpenConfigConstants() {
94         // Hidden on purpose
95     }
96
97     /**
98      * Return identifiers of all sources known to define the metadata extension.
99      *
100      * @return Collection of identifiers.
101      */
102     public static Collection<SourceIdentifier> knownModelSources() {
103         return ImmutableList.of(HASHED_VALUE_SOURCE, ENCRYPTED_VALUE_SOURCE, SEMVER_SOURCE);
104     }
105 }