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