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.collect.ImmutableList;
11 import java.io.Serializable;
12 import java.util.List;
13 import java.util.Objects;
14 import org.opendaylight.yangtools.concepts.Immutable;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.common.QNameModule;
18 final class QNameWithPredicateImpl implements Immutable, Serializable,
21 private static final long serialVersionUID = 1L;
23 private final List<QNamePredicate> qnamePredicates;
24 private final QNameModule moduleQname;
25 private final String localName;
27 public QNameWithPredicateImpl(final QNameModule moduleQname, final String localName,
28 final List<QNamePredicate> qnamePredicates) {
29 this.moduleQname = moduleQname;
30 this.localName = localName;
31 this.qnamePredicates = ImmutableList.copyOf(qnamePredicates);
35 public List<QNamePredicate> getQNamePredicates() {
36 return qnamePredicates;
40 public QNameModule getModuleQname() {
45 public String getLocalName() {
50 public QName getQName() {
51 return QName.create(moduleQname, localName);
54 // FIXME: check also predicates ...
56 public boolean equals(final Object obj) {
60 if (!(obj instanceof QNameWithPredicateImpl)) {
63 final QNameWithPredicateImpl other = (QNameWithPredicateImpl) obj;
64 return Objects.equals(localName, other.localName) && moduleQname.equals(other.moduleQname);
68 public int hashCode() {
69 int result = moduleQname != null ? moduleQname.hashCode() : 0;
70 result = 31 * result + (localName != null ? localName.hashCode() : 0);
75 public String toString() {
76 final StringBuilder sb = new StringBuilder();
78 if (moduleQname != null) {
79 sb.append('(').append(moduleQname.getNamespace());
80 sb.append("?revision=").append(moduleQname.getRevision());
86 for (final QNamePredicate predicate : qnamePredicates) {