e2de0ed8ce5f1ecf0d1393c2aba472296358c53c
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / utils / parser / ParserConstants.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, 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.restconf.nb.rfc8040.utils.parser;
9
10 import com.google.common.base.CharMatcher;
11
12 /**
13  * Various constants related to RFC3986 (URI) and RFC7950 (YANG) parsing in the context of RFC8040.
14  */
15 final class ParserConstants {
16     // Reserved characters as per https://tools.ietf.org/html/rfc3986#section-2.2
17     static final String RFC3986_RESERVED_CHARACTERS = ":/?#[]@" + "!$&'()*+,;="
18             // FIXME: this space should not be here, but that was a day-0 bug and we have asserts on this
19             + " ";
20
21     // First character of RFC7950 "identifier" rule
22     static final CharMatcher YANG_IDENTIFIER_START =
23             CharMatcher.inRange('A', 'Z').or(CharMatcher.inRange('a', 'z').or(CharMatcher.is('_'))).precomputed();
24     // Subsequent characters of RFC7950 "identifier" rule
25     static final CharMatcher YANG_IDENTIFIER_PART =
26             YANG_IDENTIFIER_START.or(CharMatcher.inRange('0', '9')).or(CharMatcher.anyOf("-.")).precomputed();
27
28     private ParserConstants() {
29         // Hidden on purpose
30     }
31 }