2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.util.Objects;
11 import java.util.Optional;
12 import org.opendaylight.yangtools.concepts.Immutable;
13 import org.opendaylight.yangtools.yang.common.QNameModule;
14 import org.opendaylight.yangtools.yang.common.Revision;
16 abstract class AbstractQNameWithPredicate implements Immutable, QNameWithPredicate {
18 public final boolean equals(final Object obj) {
22 if (!(obj instanceof QNameWithPredicate)) {
25 final QNameWithPredicate other = (QNameWithPredicate) obj;
26 // FIXME: check also predicates ...
27 return Objects.equals(getLocalName(), other.getLocalName())
28 && Objects.equals(getModuleQname(), other.getModuleQname());
32 public final int hashCode() {
33 return Objects.hash(getModuleQname(), getLocalName());
37 public final String toString() {
38 final StringBuilder sb = new StringBuilder();
40 final QNameModule moduleQname = getModuleQname();
41 if (moduleQname != null) {
42 sb.append('(').append(moduleQname.getNamespace());
43 final Optional<Revision> rev = moduleQname.getRevision();
44 if (rev.isPresent()) {
45 sb.append("?revision=").append(rev.get());
50 sb.append(getLocalName());
51 getQNamePredicates().forEach(sb::append);