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.Optional;
11 import com.google.common.base.Preconditions;
12 import java.util.Collection;
13 import org.opendaylight.controller.md.sal.dom.spi.RegistrationTreeNode;
14 import org.opendaylight.controller.md.sal.dom.store.impl.DataChangeListenerRegistration;
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 public class ListenerNode implements StoreTreeNode<ListenerNode>, Identifiable<PathArgument> {
28 final RegistrationTreeNode<DataChangeListenerRegistration<?>> delegate;
30 ListenerNode(final RegistrationTreeNode<DataChangeListenerRegistration<?>> delegate) {
31 this.delegate = Preconditions.checkNotNull(delegate);
35 public PathArgument getIdentifier() {
36 return delegate.getIdentifier();
40 public Optional<ListenerNode> getChild(final PathArgument child) {
41 final RegistrationTreeNode<DataChangeListenerRegistration<?>> c = delegate.getExactChild(child);
43 return Optional.absent();
46 return Optional.of(new ListenerNode(c));
50 * Return the list of current listeners. This collection is guaranteed
51 * to be immutable only while the walker, through which this node is
52 * reachable remains unclosed.
54 * @return the list of current listeners
56 public Collection<DataChangeListenerRegistration<?>> getListeners() {
57 return delegate.getRegistrations();
61 public int hashCode() {
62 return delegate.hashCode();
66 public boolean equals(final Object obj) {
67 return delegate.equals(obj);
71 public String toString() {
72 return delegate.toString();