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 static java.util.Objects.requireNonNull;
12 import java.io.Serializable;
13 import org.opendaylight.yangtools.concepts.Immutable;
14 import org.opendaylight.yangtools.yang.common.QName;
16 class QNamePredicateImpl implements Immutable, Serializable, QNamePredicate {
17 private static final long serialVersionUID = 1L;
19 private final QName identifier;
20 private final LeafRefPath pathKeyExpression;
22 QNamePredicateImpl(final QName identifier, final LeafRefPath pathKeyExpression) {
23 this.identifier = requireNonNull(identifier, "QNamePredicate: identifier should not be null");
24 this.pathKeyExpression = requireNonNull(pathKeyExpression,
25 "QNamePredicate: pathKeyExpression should not be null");
29 public QName getIdentifier() {
34 public LeafRefPath getPathKeyExpression() {
35 return pathKeyExpression;
39 public String toString() {
40 final StringBuilder sb = new StringBuilder();
41 sb.append('[').append(identifier).append("=current()");
43 for (final QNameWithPredicate qname : pathKeyExpression.getPathFromRoot()) {
44 sb.append('/').append(qname);
47 return sb.append(']').toString();