2 * Copyright (c) 2015 Cisco Systems, Inc. and others. 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.data.tree.leafref;
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.yangtools.concepts.Mutable;
12 import org.opendaylight.yangtools.yang.common.QName;
14 final class QNamePredicateBuilder implements Mutable {
15 private QName identifier;
16 private LeafRefPath pathKeyExpression;
18 QNamePredicateBuilder() {
22 QNamePredicateBuilder(final QName identifier, final LeafRefPath pathKeyExpression) {
23 this.identifier = identifier;
24 this.pathKeyExpression = pathKeyExpression;
27 public QName getIdentifier() {
31 public void setIdentifier(final QName identifier) {
32 this.identifier = identifier;
35 public LeafRefPath getPathKeyExpression() {
36 return pathKeyExpression;
39 public void setPathKeyExpression(final LeafRefPath pathKeyExpression) {
40 this.pathKeyExpression = pathKeyExpression;
43 public @NonNull QNamePredicate build() {
44 return new QNamePredicateImpl(identifier, pathKeyExpression);
48 public String toString() {
49 final StringBuilder sb = new StringBuilder();
52 sb.append(identifier);
53 sb.append("=current()");
55 for (final QNameWithPredicate qname : pathKeyExpression.getPathFromRoot()) {
56 sb.append('/').append(qname);