2 * Copyright (c) 2014 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.controller.md.sal.dom.store.impl.tree;
10 import com.google.common.base.Preconditions;
11 import java.util.Collection;
12 import java.util.Optional;
13 import org.opendaylight.controller.md.sal.dom.store.impl.DataChangeListenerRegistration;
14 import org.opendaylight.mdsal.dom.spi.RegistrationTreeNode;
15 import org.opendaylight.yangtools.concepts.Identifiable;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
17 import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNode;
20 * This is a single node within the listener tree. Note that the data returned from
21 * and instance of this class is guaranteed to have any relevance or consistency
22 * only as long as the {@link ListenerWalker} instance through which it is reached remains
25 * @author Robert Varga
27 * @deprecated Use {@link RegistrationTreeNode} instead.
30 public class ListenerNode implements StoreTreeNode<ListenerNode>, Identifiable<PathArgument> {
31 final RegistrationTreeNode<DataChangeListenerRegistration<?>> delegate;
33 ListenerNode(final RegistrationTreeNode<DataChangeListenerRegistration<?>> delegate) {
34 this.delegate = Preconditions.checkNotNull(delegate);
38 public PathArgument getIdentifier() {
39 return delegate.getIdentifier();
43 public Optional<ListenerNode> getChild(final PathArgument child) {
44 final RegistrationTreeNode<DataChangeListenerRegistration<?>> c = delegate.getExactChild(child);
46 return Optional.empty();
49 return Optional.of(new ListenerNode(c));
53 * Return the list of current listeners. This collection is guaranteed
54 * to be immutable only while the walker, through which this node is
55 * reachable remains unclosed.
57 * @return the list of current listeners
59 public Collection<DataChangeListenerRegistration<?>> getListeners() {
60 return delegate.getRegistrations();
64 public int hashCode() {
65 return delegate.hashCode();
69 public boolean equals(final Object obj) {
70 if (obj == null || getClass() != obj.getClass()) {
74 return delegate.equals(((ListenerNode)obj).delegate);
78 public String toString() {
79 return delegate.toString();