Merge branch 'mdsal-trace' from controller
[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.ActionProviderService;
16 import org.opendaylight.mdsal.binding.api.ActionService;
17 import org.opendaylight.mdsal.binding.api.DataBroker;
18 import org.opendaylight.mdsal.binding.api.DataTreeService;
19 import org.opendaylight.mdsal.binding.api.MountPointService;
20 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
21 import org.opendaylight.mdsal.binding.api.NotificationService;
22 import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
23 import org.opendaylight.mdsal.binding.api.RpcProviderService;
24 import org.opendaylight.mdsal.binding.dom.adapter.spi.AdapterFactory;
25 import org.opendaylight.mdsal.dom.api.DOMActionProviderService;
26 import org.opendaylight.mdsal.dom.api.DOMActionService;
27 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
28 import org.opendaylight.mdsal.dom.api.DOMDataTreeService;
29 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
30 import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
31 import org.opendaylight.mdsal.dom.api.DOMNotificationService;
32 import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
33 import org.opendaylight.mdsal.dom.api.DOMRpcService;
34
35 /**
36  * Implementation of AdapterFactory.
37  *
38  * @author Robert Varga
39  */
40 @Beta
41 @NonNullByDefault
42 @ThreadSafe
43 public final class BindingAdapterFactory implements AdapterFactory {
44     private final BindingToNormalizedNodeCodec codec;
45
46     public BindingAdapterFactory(final BindingToNormalizedNodeCodec codec) {
47         this.codec = requireNonNull(codec);
48     }
49
50     /**
51      * Create a {@link DataBroker} backed by a {@link DOMDataBroker}.
52      *
53      * @param domService Backing DOMDataBroker
54      * @return A DataBroker
55      * @throws NullPointerException if {@code domService} is null
56      */
57     @Override
58     public DataBroker createDataBroker(final DOMDataBroker domService) {
59         return new BindingDOMDataBrokerAdapter(domService, codec);
60     }
61
62     /**
63      * Create a {@link DataTreeService} backed by a {@link DOMDataTreeService}.
64      *
65      * @param domService Backing DOMDataTreeService
66      * @return A DataTreeService
67      * @throws NullPointerException if {@code domService} is null
68      */
69     @Override
70     public DataTreeService createDataTreeService(final DOMDataTreeService domService) {
71         return BindingDOMDataTreeServiceAdapter.create(domService, codec);
72     }
73
74     /**
75      * Create a {@link MountPointService} backed by a {@link DOMMountPointService}.
76      *
77      * @param domService Backing DOMMountPointService
78      * @return A MountPointService
79      * @throws NullPointerException if {@code domService} is null
80      */
81     @Override
82     public MountPointService createMountPointService(final DOMMountPointService domService) {
83         return new BindingDOMMountPointServiceAdapter(domService, codec);
84     }
85
86     /**
87      * Create a {@link DataBroker} backed by a {@link DOMDataBroker}.
88      *
89      * @param domService Backing DOMDataBroker
90      * @return A DataBroker
91      * @throws NullPointerException if {@code domService} is null
92      */
93     @Override
94     public NotificationService createNotificationService(final DOMNotificationService domService) {
95         return new BindingDOMNotificationServiceAdapter(domService, codec);
96     }
97
98     /**
99      * Create a {@link NotificationPublishService} backed by a {@link DOMNotificationPublishService}.
100      *
101      * @param domService Backing DOMNotificationPublishService
102      * @return A NotificationPublishService
103      * @throws NullPointerException if {@code domService} is null
104      */
105     @Override
106     public NotificationPublishService createNotificationPublishService(final DOMNotificationPublishService domService) {
107         return new BindingDOMNotificationPublishServiceAdapter(domService, codec);
108     }
109
110     /**
111      * Create a {@link RpcConsumerRegistry} backed by a {@link DOMRpcService}.
112      *
113      * @param domService Backing DOMRpcService
114      * @return A RpcConsumerRegistry
115      * @throws NullPointerException if {@code domService} is null
116      */
117     @Override
118     public RpcConsumerRegistry createRpcConsumerRegistry(final DOMRpcService domService) {
119         return new BindingDOMRpcServiceAdapter(domService, codec);
120     }
121
122     /**
123      * Create a {@link RpcProviderService} backed by a {@link DOMRpcProviderService}.
124      *
125      * @param domService Backing DOMRpcProviderService
126      * @return A RpcProviderService
127      * @throws NullPointerException if {@code domService} is null
128      */
129     @Override
130     public RpcProviderService createRpcProviderService(final DOMRpcProviderService domService) {
131         return new BindingDOMRpcProviderServiceAdapter(domService, codec);
132     }
133
134     @Override
135     public ActionService createActionService(final DOMActionService domService) {
136         return new ActionServiceAdapter(codec, domService);
137     }
138
139     @Override
140     public ActionProviderService createActionProviderService(final DOMActionProviderService domService) {
141         return new ActionProviderServiceAdapter(codec, domService);
142     }
143 }