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.test.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.RpcService;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 public class MountPointStub implements MountPoint {
19 private DataBroker dataBroker;
21 private RpcService rpcService;
23 public MountPointStub(DataBroker dataBroker) {
24 this.dataBroker = dataBroker;
27 public void setRpcService(RpcService rpcService) {
28 this.rpcService = rpcService;
32 @SuppressWarnings("unchecked")
33 public <T extends BindingService> Optional<T> getService(Class<T> service) {
34 if (service.isInstance(dataBroker)) {
35 return Optional.ofNullable((T) dataBroker);
37 if (service.isInstance(rpcService)) {
38 return Optional.ofNullable((T) rpcService);
40 return Optional.empty();
44 public InstanceIdentifier<?> getIdentifier() {
45 throw new UnsupportedOperationException();