Remove unnecessary code
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / md / sal / binding / compat / HydrogenDataChangeEvent.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.controller.md.sal.binding.compat;
9
10 import java.util.Collections;
11 import java.util.HashMap;
12 import java.util.Map;
13 import java.util.Set;
14 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
15 import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18
19 @Deprecated
20 public abstract class HydrogenDataChangeEvent implements
21         DataChangeEvent<InstanceIdentifier<? extends DataObject>, DataObject> {
22
23     private HydrogenDataChangeEvent() {
24     }
25
26     public static final DataChangeEvent<InstanceIdentifier<?>, DataObject> createOperational(
27             final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
28         return new OperationalChangeEvent(change);
29     }
30
31     public static final DataChangeEvent<InstanceIdentifier<?>, DataObject> createConfiguration(
32             final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
33         return new ConfigurationChangeEvent(change);
34     }
35
36     @Override
37     public Map<InstanceIdentifier<?>, DataObject> getCreatedOperationalData() {
38         return Collections.emptyMap();
39     }
40
41     @Override
42     public Map<InstanceIdentifier<?>, DataObject> getCreatedConfigurationData() {
43         return Collections.emptyMap();
44     }
45
46     @Override
47     public Map<InstanceIdentifier<?>, DataObject> getUpdatedOperationalData() {
48         return Collections.emptyMap();
49     }
50
51     @Override
52     public Map<InstanceIdentifier<?>, DataObject> getUpdatedConfigurationData() {
53         return Collections.emptyMap();
54     }
55
56     @Override
57     public Set<InstanceIdentifier<?>> getRemovedConfigurationData() {
58         return Collections.emptySet();
59     }
60
61     @Override
62     public Set<InstanceIdentifier<?>> getRemovedOperationalData() {
63         return Collections.emptySet();
64     }
65
66     @Override
67     public Map<InstanceIdentifier<?>, DataObject> getOriginalConfigurationData() {
68         return Collections.emptyMap();
69     }
70
71     @Override
72     public Map<InstanceIdentifier<?>, DataObject> getOriginalOperationalData() {
73         return Collections.emptyMap();
74     }
75
76     @Override
77     public DataObject getOriginalConfigurationSubtree() {
78         return null;
79     }
80
81     @Override
82     public DataObject getOriginalOperationalSubtree() {
83         return null;
84     }
85
86     @Override
87     public DataObject getUpdatedConfigurationSubtree() {
88         return null;
89     }
90
91     @Override
92     public DataObject getUpdatedOperationalSubtree() {
93         return null;
94     }
95
96     private static final class OperationalChangeEvent extends HydrogenDataChangeEvent {
97
98         private final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> delegate;
99         private Map<InstanceIdentifier<?>, DataObject> updatedCache;
100
101         public OperationalChangeEvent(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
102             this.delegate = change;
103         }
104
105         @Override
106         public Map<InstanceIdentifier<?>, DataObject> getCreatedOperationalData() {
107             return delegate.getCreatedData();
108         }
109
110         @Override
111         public Set<InstanceIdentifier<?>> getRemovedOperationalData() {
112             return delegate.getRemovedPaths();
113         }
114
115         @Override
116         public DataObject getOriginalOperationalSubtree() {
117             return delegate.getOriginalSubtree();
118         }
119
120         @Override
121         public DataObject getUpdatedOperationalSubtree() {
122             return delegate.getUpdatedSubtree();
123         }
124
125         @Override
126         public Map<InstanceIdentifier<?>, DataObject> getOriginalOperationalData() {
127             return delegate.getOriginalData();
128         }
129
130         @Override
131         public Map<InstanceIdentifier<?>, DataObject> getUpdatedOperationalData() {
132             if(updatedCache == null) {
133                 final Map<InstanceIdentifier<?>, DataObject> created = delegate.getCreatedData();
134                 final Map<InstanceIdentifier<?>, DataObject> updated = delegate.getUpdatedData();
135                 final Map<InstanceIdentifier<?>, DataObject> updatedComposite =
136                         new HashMap<>(created.size() + updated.size());
137                 updatedComposite.putAll(created);
138                 updatedComposite.putAll(updated);
139                 updatedCache = Collections.unmodifiableMap(updatedComposite);
140             }
141             return updatedCache;
142         }
143
144         @Override
145         public String toString() {
146             return "OperationalChangeEvent [delegate=" + delegate + "]";
147         }
148
149     }
150
151     private static final class ConfigurationChangeEvent extends HydrogenDataChangeEvent {
152
153         private final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> delegate;
154         private Map<InstanceIdentifier<?>, DataObject> updatedCache;
155
156         public ConfigurationChangeEvent(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
157             this.delegate = change;
158         }
159
160         @Override
161         public Map<InstanceIdentifier<?>, DataObject> getCreatedConfigurationData() {
162             return delegate.getCreatedData();
163         }
164
165         @Override
166         public Set<InstanceIdentifier<?>> getRemovedConfigurationData() {
167             return delegate.getRemovedPaths();
168         }
169
170         @Override
171         public DataObject getOriginalConfigurationSubtree() {
172             return delegate.getOriginalSubtree();
173         }
174
175         @Override
176         public DataObject getUpdatedConfigurationSubtree() {
177             return delegate.getUpdatedSubtree();
178         }
179
180         @Override
181         public Map<InstanceIdentifier<?>, DataObject> getOriginalConfigurationData() {
182             return delegate.getOriginalData();
183         }
184
185         @Override
186         public Map<InstanceIdentifier<?>, DataObject> getUpdatedConfigurationData() {
187             if(updatedCache == null) {
188                 final Map<InstanceIdentifier<?>, DataObject> created = delegate.getCreatedData();
189                 final Map<InstanceIdentifier<?>, DataObject> updated = delegate.getUpdatedData();
190                 final Map<InstanceIdentifier<?>, DataObject> updatedComposite =
191                         new HashMap<>(created.size() + updated.size());
192                 updatedComposite.putAll(created);
193                 updatedComposite.putAll(updated);
194                 updatedCache = Collections.unmodifiableMap(updatedComposite);
195             }
196             return updatedCache;
197         }
198
199         @Override
200         public String toString() {
201             return "ConfigurationChangeEvent [delegate=" + delegate + "]";
202         }
203
204     }
205
206 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.