2 * Copyright © 2018 Orange 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.transportpce.olm.stub;
10 import java.util.Optional;
11 import org.opendaylight.mdsal.binding.api.BindingService;
12 import org.opendaylight.mdsal.binding.api.DataBroker;
13 import org.opendaylight.mdsal.binding.api.MountPoint;
14 import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 public class MountPointStub implements MountPoint {
19 private DataBroker dataBroker;
21 private RpcConsumerRegistry rpcConsumerRegistry;
23 public MountPointStub(DataBroker dataBroker) {
25 this.dataBroker = dataBroker;
28 public void setRpcConsumerRegistry(RpcConsumerRegistry rpcConsumerRegistry) {
29 this.rpcConsumerRegistry = rpcConsumerRegistry;
33 @SuppressWarnings("unchecked")
34 public <T extends BindingService> Optional<T> getService(Class<T> service) {
35 if (service.isInstance(dataBroker)) {
36 return Optional.ofNullable((T)dataBroker);
38 if (service.isInstance(rpcConsumerRegistry)) {
39 return Optional.ofNullable((T)rpcConsumerRegistry);
41 return Optional.empty();
45 public InstanceIdentifier<?> getIdentifier() {