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.impl.leafref;
10 import com.google.common.base.Preconditions;
11 import java.io.Serializable;
12 import org.opendaylight.yangtools.concepts.Immutable;
13 import org.opendaylight.yangtools.yang.common.QName;
15 class QNamePredicateImpl implements Immutable, Serializable, QNamePredicate {
17 private static final long serialVersionUID = 1L;
18 private final QName identifier;
19 private final LeafRefPath pathKeyExpression;
21 public QNamePredicateImpl(final QName identifier, final LeafRefPath pathKeyExpression) {
22 this.identifier = Preconditions.checkNotNull(identifier, "QNamePredicate: identifier should not be null");
23 this.pathKeyExpression = Preconditions.checkNotNull(pathKeyExpression, "QNamePredicate: pathKeyExpression should not be null");
27 public QName getIdentifier() {
32 public LeafRefPath getPathKeyExpression() {
33 return pathKeyExpression;
37 public String toString() {
38 final StringBuilder sb = new StringBuilder();
41 sb.append(identifier);
42 sb.append("=current()");
44 final Iterable<QNameWithPredicate> pathFromRoot = pathKeyExpression
47 for (final QNameWithPredicate qName : pathFromRoot) {
48 sb.append('/').append(qName);