Define PathExpression is a separate concept
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / PathExpression.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech, s.r.o.  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.yang.model.api;
9
10 import com.google.common.annotations.Beta;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.yangtools.concepts.Immutable;
13 import org.opendaylight.yangtools.yang.xpath.api.YangBinaryOperator;
14 import org.opendaylight.yangtools.yang.xpath.api.YangFunction;
15 import org.opendaylight.yangtools.yang.xpath.api.YangLocationPath;
16 import org.opendaylight.yangtools.yang.xpath.api.YangLocationPath.QNameStep;
17 import org.opendaylight.yangtools.yang.xpath.api.YangXPathAxis;
18 import org.opendaylight.yangtools.yang.xpath.api.YangXPathExpression;
19
20 /**
21  * An expression as defined in <a href="https://tools.ietf.org/html/rfc7950#section-9.9.2">RFC7950 Section 9.9.2</a>,
22  * i.e. the argument of a {@code path} statement.
23  *
24  * <p>
25  * Semantically a {@link PathExpression} is similar to a {@link YangXPathExpression} with guarantees around what
26  * subexpressions it can contain:
27  * <ul>
28  * <li>the root expression must be a {@link YangLocationPath}</li>
29  * <li>it can contain steps only along {@link YangXPathAxis#DESCENDANT} and {@link YangXPathAxis#PARENT} axis</li>
30  * <li>all steps along {@link YangXPathAxis#DESCENDANT} axis are {@link QNameStep}</li>
31  * <li>the only function invocation is {@link YangFunction#CURRENT}</li>
32  * <li>only {@link YangBinaryOperator#EQUALS} is allowed</li>
33  * <li>no literals nor numbers are allowed</li>
34  * </ul>
35  *
36  * @author Robert Varga
37  */
38 @Beta
39 public interface PathExpression extends Immutable {
40     /**
41      * Return the {@link YangLocationPath} of this expression.
42      *
43      * @return The location path
44      */
45     @NonNull YangLocationPath getLocation();
46 }