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.binding.util;
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;
14 public final class TypeSafeDataReader {
16 private final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate;
18 public DataReader<InstanceIdentifier<?>, DataObject> getDelegate() {
22 public TypeSafeDataReader(DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate) {
23 this.delegate = delegate;
26 @SuppressWarnings("unchecked")
27 public <D extends DataObject> D readConfigurationData(InstanceIdentifier<D> path) {
28 return (D) delegate.readConfigurationData(path);
31 @SuppressWarnings("unchecked")
32 public <D extends DataObject> D readOperationalData(InstanceIdentifier<D> path) {
33 return (D) delegate.readOperationalData(path);
36 public static TypeSafeDataReader forReader(DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate) {
37 return new TypeSafeDataReader(delegate);