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.io.Serializable;
11 import java.util.Objects;
12 import java.util.Optional;
13 import org.opendaylight.yangtools.concepts.Immutable;
14 import org.opendaylight.yangtools.yang.common.QNameModule;
15 import org.opendaylight.yangtools.yang.common.Revision;
17 abstract class AbstractQNameWithPredicate implements Immutable, Serializable, QNameWithPredicate {
18 private static final long serialVersionUID = 1L;
21 public final boolean equals(final Object obj) {
25 if (!(obj instanceof QNameWithPredicate)) {
28 final QNameWithPredicate other = (QNameWithPredicate) obj;
29 // FIXME: check also predicates ...
30 return Objects.equals(getLocalName(), other.getLocalName())
31 && Objects.equals(getModuleQname(), other.getModuleQname());
35 public final int hashCode() {
36 return Objects.hash(getModuleQname(), getLocalName());
40 public final String toString() {
41 final StringBuilder sb = new StringBuilder();
43 final QNameModule moduleQname = getModuleQname();
44 if (moduleQname != null) {
45 sb.append('(').append(moduleQname.getNamespace());
46 final Optional<Revision> rev = moduleQname.getRevision();
47 if (rev.isPresent()) {
48 sb.append("?revision=").append(rev.get());
53 sb.append(getLocalName());
54 getQNamePredicates().forEach(sb::append);