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 java.io.Serializable;
11 import java.util.List;
12 import java.util.Objects;
13 import org.opendaylight.yangtools.concepts.Immutable;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.common.QNameModule;
17 final class QNameWithPredicateImpl implements Immutable, Serializable,
20 private static final long serialVersionUID = 1L;
22 private final List<QNamePredicate> qnamePredicates;
23 private final QNameModule moduleQname;
24 private final String localName;
26 public QNameWithPredicateImpl(final QNameModule moduleQname, final String localName,
27 final List<QNamePredicate> qnamePredicates) {
28 this.moduleQname = moduleQname;
29 this.localName = localName;
30 this.qnamePredicates = qnamePredicates;
34 public List<QNamePredicate> getQNamePredicates() {
35 return qnamePredicates;
39 public QNameModule getModuleQname() {
44 public String getLocalName() {
49 public QName getQName() {
50 return QName.create(moduleQname, localName);
53 // FIXME: check also predicates ...
55 public boolean equals(final Object obj) {
59 if (!(obj instanceof QNameWithPredicateImpl)) {
62 final QNameWithPredicateImpl other = (QNameWithPredicateImpl) obj;
63 return Objects.equals(localName, other.localName) && moduleQname.equals(other.moduleQname);
67 public int hashCode() {
68 int result = moduleQname != null ? moduleQname.hashCode() : 0;
69 result = 31 * result + (localName != null ? localName.hashCode() : 0);
74 public String toString() {
75 final StringBuilder sb = new StringBuilder();
77 if (moduleQname != null) {
78 sb.append('(').append(moduleQname.getNamespace());
79 sb.append("?revision=").append(moduleQname.getRevision());
85 for (final QNamePredicate predicate : qnamePredicates) {