fix Databroker deprecated warnings
[transportpce.git] / olm / src / test / java / org / opendaylight / transportpce / olm / stub / MountPointStub.java
1 /*
2  * Copyright © 2018 Orange 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
9 package org.opendaylight.transportpce.olm.stub;
10
11 import java.util.Optional;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.mdsal.binding.api.BindingService;
14 import org.opendaylight.mdsal.binding.api.DataBroker;
15 import org.opendaylight.mdsal.binding.api.MountPoint;
16 import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18
19 public class MountPointStub  implements MountPoint {
20
21     private DataBroker dataBroker;
22
23     private RpcConsumerRegistry rpcConsumerRegistry;
24
25     public MountPointStub(DataBroker dataBroker) {
26
27         this.dataBroker = dataBroker;
28     }
29
30     public void setRpcConsumerRegistry(RpcConsumerRegistry rpcConsumerRegistry) {
31         this.rpcConsumerRegistry = rpcConsumerRegistry;
32     }
33
34     @Override
35     public <T extends BindingService> Optional<T> getService(Class<T> service) {
36         if (service.isInstance(dataBroker)) {
37             return Optional.ofNullable((T)dataBroker);
38         }
39         if (service.isInstance(rpcConsumerRegistry)) {
40             return Optional.ofNullable((T)rpcConsumerRegistry);
41         }
42         return Optional.empty();
43     }
44
45     @Nonnull
46     @Override
47     public InstanceIdentifier<?> getIdentifier() {
48         return null;
49     }
50 }