e71f646f2e2cc4748994ae64b3d98270c1adf811
[controller.git] / opendaylight / md-sal / sal-binding-util / src / main / java / org / opendaylight / controller / md / sal / binding / util / TypeSafeDataReader.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.util;
9
10 import org.opendaylight.controller.md.sal.common.api.data.DataReader;
11 import org.opendaylight.yangtools.yang.binding.DataObject;
12 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
13
14 /**
15  * Deprecated.
16  *
17  * @deprecated Use {@link org.opendaylight.controller.md.sal.binding.api.ReadTransaction#read(
18  *     org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType, InstanceIdentifier)} instead.
19  */
20 @Deprecated
21 public final class TypeSafeDataReader {
22
23     private final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate;
24
25     public DataReader<InstanceIdentifier<?>, DataObject> getDelegate() {
26         return delegate;
27     }
28
29     public TypeSafeDataReader(
30             final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate) {
31         this.delegate = delegate;
32     }
33
34     @SuppressWarnings("unchecked")
35     public <D extends DataObject> D readConfigurationData(
36             final InstanceIdentifier<D> path) {
37         return (D) delegate.readConfigurationData(path);
38     }
39
40     @SuppressWarnings("unchecked")
41     public <D extends DataObject> D readOperationalData(
42             final InstanceIdentifier<D> path) {
43         return (D) delegate.readOperationalData(path);
44     }
45
46     public static TypeSafeDataReader forReader(
47             final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate) {
48         return new TypeSafeDataReader(delegate);
49     }
50 }

©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.