Renamed Data(ReadOnly|WriteOnly) to DataTree(Read|Write)
[mdsal.git] / dom / mdsal-dom-inmemory-datastore / src / main / java / org / opendaylight / mdsal / dom / store / inmemory / tree / ListenerNode.java
1 /**
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.dom.store.inmemory.tree;
9
10 import org.opendaylight.mdsal.dom.store.inmemory.DataChangeListenerRegistration;
11
12 import org.opendaylight.mdsal.dom.spi.RegistrationTreeNode;
13 import com.google.common.base.Optional;
14 import com.google.common.base.Preconditions;
15 import java.util.Collection;
16 import org.opendaylight.yangtools.concepts.Identifiable;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
18 import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNode;
19
20 /**
21  * This is a single node within the listener tree. Note that the data returned from
22  * and instance of this class is guaranteed to have any relevance or consistency
23  * only as long as the {@link ListenerWalker} instance through which it is reached remains
24  * unclosed.
25  *
26  * @author Robert Varga
27  *
28  * @deprecated Use {@link RegistrationTreeNode} instead.
29  */
30 @Deprecated
31 public class ListenerNode implements StoreTreeNode<ListenerNode>, Identifiable<PathArgument> {
32     final RegistrationTreeNode<DataChangeListenerRegistration<?>> delegate;
33
34     ListenerNode(final RegistrationTreeNode<DataChangeListenerRegistration<?>> delegate) {
35         this.delegate = Preconditions.checkNotNull(delegate);
36     }
37
38     @Override
39     public PathArgument getIdentifier() {
40         return delegate.getIdentifier();
41     }
42
43     @Override
44     public Optional<ListenerNode> getChild(final PathArgument child) {
45         final RegistrationTreeNode<DataChangeListenerRegistration<?>> c = delegate.getExactChild(child);
46         if (c == null) {
47             return Optional.absent();
48         }
49
50         return Optional.of(new ListenerNode(c));
51     }
52
53     /**
54      * Return the list of current listeners. This collection is guaranteed
55      * to be immutable only while the walker, through which this node is
56      * reachable remains unclosed.
57      *
58      * @return the list of current listeners
59      */
60     public Collection<DataChangeListenerRegistration<?>> getListeners() {
61         return delegate.getRegistrations();
62     }
63
64     @Override
65     public int hashCode() {
66         return delegate.hashCode();
67     }
68
69     @Override
70     public boolean equals(final Object obj) {
71         return delegate.equals(obj);
72     }
73
74     @Override
75     public String toString() {
76         return delegate.toString();
77     }
78 }