79ac49860bdaa1ff3ae3c15725958de8dcdfd175
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / main / java / org / opendaylight / mdsal / binding / dom / adapter / BindingAdapterFactory.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.mdsal.binding.dom.adapter;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import javax.annotation.concurrent.ThreadSafe;
14 import org.eclipse.jdt.annotation.NonNullByDefault;
15 import org.opendaylight.mdsal.binding.api.DataBroker;
16 import org.opendaylight.mdsal.binding.api.DataTreeService;
17 import org.opendaylight.mdsal.binding.api.MountPointService;
18 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
19 import org.opendaylight.mdsal.binding.api.NotificationService;
20 import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
21 import org.opendaylight.mdsal.binding.api.RpcProviderService;
22 import org.opendaylight.mdsal.binding.dom.adapter.spi.AdapterFactory;
23 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
24 import org.opendaylight.mdsal.dom.api.DOMDataTreeService;
25 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
26 import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
27 import org.opendaylight.mdsal.dom.api.DOMNotificationService;
28 import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
29 import org.opendaylight.mdsal.dom.api.DOMRpcService;
30
31 /**
32  * Implementation of AdapterFactory.
33  *
34  * @author Robert Varga
35  */
36 @Beta
37 @NonNullByDefault
38 @ThreadSafe
39 public final class BindingAdapterFactory implements AdapterFactory {
40     private final BindingToNormalizedNodeCodec codec;
41
42     public BindingAdapterFactory(final BindingToNormalizedNodeCodec codec) {
43         this.codec = requireNonNull(codec);
44     }
45
46     /**
47      * Create a {@link DataBroker} backed by a {@link DOMDataBroker}.
48      *
49      * @param domService Backing DOMDataBroker
50      * @return A DataBroker
51      * @throws NullPointerException if {@code domService} is null
52      */
53     @Override
54     public DataBroker createDataBroker(final DOMDataBroker domService) {
55         return new BindingDOMDataBrokerAdapter(domService, codec);
56     }
57
58     /**
59      * Create a {@link DataTreeService} backed by a {@link DOMDataTreeService}.
60      *
61      * @param domService Backing DOMDataTreeService
62      * @return A DataTreeService
63      * @throws NullPointerException if {@code domService} is null
64      */
65     @Override
66     public DataTreeService createDataTreeService(final DOMDataTreeService domService) {
67         return BindingDOMDataTreeServiceAdapter.create(domService, codec);
68     }
69
70     /**
71      * Create a {@link MountPointService} backed by a {@link DOMMountPointService}.
72      *
73      * @param domService Backing DOMMountPointService
74      * @return A MountPointService
75      * @throws NullPointerException if {@code domService} is null
76      */
77     @Override
78     public MountPointService createMountPointService(final DOMMountPointService domService) {
79         return new BindingDOMMountPointServiceAdapter(domService, codec);
80     }
81
82     /**
83      * Create a {@link DataBroker} backed by a {@link DOMDataBroker}.
84      *
85      * @param domService Backing DOMDataBroker
86      * @return A DataBroker
87      * @throws NullPointerException if {@code domService} is null
88      */
89     @Override
90     public NotificationService createNotificationService(final DOMNotificationService domService) {
91         return new BindingDOMNotificationServiceAdapter(domService, codec);
92     }
93
94     /**
95      * Create a {@link NotificationPublishService} backed by a {@link DOMNotificationPublishService}.
96      *
97      * @param domService Backing DOMNotificationPublishService
98      * @return A NotificationPublishService
99      * @throws NullPointerException if {@code domService} is null
100      */
101     @Override
102     public NotificationPublishService createNotificationPublishService(final DOMNotificationPublishService domService) {
103         return new BindingDOMNotificationPublishServiceAdapter(domService, codec);
104     }
105
106     /**
107      * Create a {@link RpcConsumerRegistry} backed by a {@link DOMRpcService}.
108      *
109      * @param domService Backing DOMRpcService
110      * @return A RpcConsumerRegistry
111      * @throws NullPointerException if {@code domService} is null
112      */
113     @Override
114     public RpcConsumerRegistry createRpcConsumerRegistry(final DOMRpcService domService) {
115         return new BindingDOMRpcServiceAdapter(domService, codec);
116     }
117
118     /**
119      * Create a {@link RpcProviderService} backed by a {@link DOMRpcProviderService}.
120      *
121      * @param domService Backing DOMRpcProviderService
122      * @return A RpcProviderService
123      * @throws NullPointerException if {@code domService} is null
124      */
125     @Override
126     public RpcProviderService createRpcProviderService(final DOMRpcProviderService domService) {
127         return new BindingDOMRpcProviderServiceAdapter(domService, codec);
128     }
129 }