2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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.model.api;
10 import com.google.common.annotations.Beta;
11 import org.eclipse.jdt.annotation.NonNullByDefault;
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;
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.
25 * Semantically a {@link PathExpression} is similar to a {@link YangXPathExpression} with guarantees around what
26 * subexpressions it can contain:
28 * <li>the root expression must be a {@link YangLocationPath}</li>
29 * <li>it can contain steps only along {@link YangXPathAxis#CHILD} and {@link YangXPathAxis#PARENT} axis</li>
30 * <li>all steps along {@link YangXPathAxis#CHILD} 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 * <li>all qualified node identifiers must me resolved</li>
37 * @author Robert Varga
41 public interface PathExpression extends Immutable {
43 * Returns the path expression formatted string as is defined in model. For example:
44 * {@code /prefix:container/prefix:container::cond[when()=foo]/prefix:leaf}
46 * @return the path expression formatted string as is defined in model.
48 String getOriginalString();
51 * Return the {@link YangLocationPath} of this expression.
53 * @return The location path
54 * @throws UnsupportedOperationException if the implementation has not parsed the string. Implementations are
55 * strongly encouraged to perform proper parsing.
57 YangLocationPath getLocation();
60 * Returns <code>true</code> if the XPapth starts in root of YANG model, otherwise returns <code>false</code>.
62 * @return <code>true</code> if the XPapth starts in root of YANG model, otherwise returns <code>false</code>
64 default boolean isAbsolute() {
65 return getLocation().isAbsolute();