Merge branch 'master' of ../controller
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / WithExpressionImpl.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.parser.rfc7950.stmt;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.base.MoreObjects;
13 import org.eclipse.jdt.annotation.NonNullByDefault;
14 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath.WithExpression;
15 import org.opendaylight.yangtools.yang.model.util.RevisionAwareXPathImpl;
16 import org.opendaylight.yangtools.yang.xpath.api.YangXPathExpression.QualifiedBound;
17
18 // TODO: disconnect from RevisionAwareXPathImpl
19 // FIXME: absolute should not be needed: since the expression is qualified, we known how to interpret it
20 // FIXME: originalString() is an escape hatch: everybody should operate of QualifiedBound
21 @NonNullByDefault
22 final class WithExpressionImpl extends RevisionAwareXPathImpl implements WithExpression {
23     private final QualifiedBound xpathExpression;
24
25     WithExpressionImpl(final String xpath, final boolean absolute, final QualifiedBound xpathExpression) {
26         super(xpath, absolute);
27         this.xpathExpression = requireNonNull(xpathExpression);
28     }
29
30     @Override
31     public QualifiedBound getXPathExpression() {
32         return xpathExpression;
33     }
34
35     @Override
36     public String toString() {
37         return MoreObjects.toStringHelper(this).add("xpath", getOriginalString()).toString();
38     }
39 }