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