Refactor DOM{Action,Rpc}Implementation
[mdsal.git] / dom / mdsal-dom-api / src / main / java / org / opendaylight / mdsal / dom / api / DOMRpcProviderService.java
1 /*
2  * Copyright (c) 2015 Cisco 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 package org.opendaylight.mdsal.dom.api;
9
10 import java.util.Map;
11 import java.util.Set;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.concepts.Registration;
14
15 /**
16  * A {@link DOMService} which allows registration of RPC implementations with a conceptual router. The client
17  * counterpart of this service is {@link DOMRpcService}.
18  */
19 public interface DOMRpcProviderService extends DOMService<DOMRpcProviderService, DOMRpcProviderService.Extension> {
20     /**
21      * Marker interface for an extension to {@link DOMRpcProviderService}.
22      */
23     interface Extension extends DOMService.Extension<DOMRpcProviderService, Extension> {
24         // Marker interface
25     }
26
27     /**
28      * Register an {@link DOMRpcImplementation} object with this service.
29      *
30      * @param implementation RPC implementation, must not be null
31      * @param rpcs Array of supported RPC identifiers. Must not be null, empty, or contain a null element.
32      *             Each identifier is added exactly once, no matter how many times it occurs.
33      * @return A {@link Registration} object, guaranteed to be non-null.
34      * @throws NullPointerException if implementation or types is null
35      * @throws IllegalArgumentException if types is empty or contains a null element.
36      */
37     default @NonNull Registration registerRpcImplementation(final @NonNull DOMRpcImplementation implementation,
38             final @NonNull DOMRpcIdentifier... rpcs) {
39         return registerRpcImplementation(implementation, Set.of(rpcs));
40     }
41
42     /**
43      * Register an {@link DOMRpcImplementation} object with this service.
44      *
45      * @param implementation RPC implementation, must not be null
46      * @param rpcs Set of supported RPC identifiers. Must not be null, empty, or contain a null element.
47      * @return A {@link Registration} object, guaranteed to be non-null.
48      * @throws NullPointerException if implementation or types is null
49      * @throws IllegalArgumentException if types is empty or contains a null element.
50      */
51     // FIXME: just Registration and forward to Map
52     @NonNull Registration registerRpcImplementation(@NonNull DOMRpcImplementation implementation,
53         @NonNull Set<DOMRpcIdentifier> rpcs);
54
55     /**
56      * Register a set of {@link DOMRpcImplementation}s with this service. The registration is performed atomically.
57      *
58      * @param map Map of RPC identifiers and their corresponding implementations
59      * @return A registration object, guaranteed to be non-null
60      * @throws NullPointerException if map is null or contains a null element
61      * @throws IllegalArgumentException if map is empty.
62      */
63     @NonNull Registration registerRpcImplementations(Map<DOMRpcIdentifier, DOMRpcImplementation> map);
64 }