Reduce ObjectRegistration use
[mdsal.git] / dom / mdsal-dom-api / src / main / java / org / opendaylight / mdsal / dom / api / DOMActionProviderService.java
1 /*
2  * Copyright (c) 2017 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 com.google.common.collect.ImmutableSet;
11 import java.util.Set;
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.opendaylight.yangtools.concepts.Registration;
14
15 /**
16  * A {@link DOMService} which allows registration of action implementations with a conceptual router. The client
17  * counterpart of this service is {@link DOMActionService}.
18  */
19 @NonNullByDefault
20 public interface DOMActionProviderService
21         extends DOMService<DOMActionProviderService, DOMActionProviderService.Extension> {
22     /**
23      * Marker interface for extensions of {@link DOMActionProviderService}.
24      */
25     interface Extension extends DOMService.Extension<DOMActionProviderService, Extension> {
26         // Marker interface
27     }
28
29     /**
30      * Register an {@link DOMActionImplementation} object with this service, servicing specified action instances.
31      *
32      * @param implementation action implementation, must not be null
33      * @param instances Set of supported operation identifiers. Must not be null, empty, or contain a null element.
34      * @return A {@link Registration} object, guaranteed to be non-null.
35      * @throws NullPointerException if {@code implementation} or {@code instances} is null, or if {@code instances}
36      *                              contains a null element.
37      * @throws IllegalArgumentException if {@code instances} is empty
38      */
39     Registration registerActionImplementation(DOMActionImplementation implementation, Set<DOMActionInstance> instances);
40
41     /**
42      * Register an {@link DOMActionImplementation} object with this service, servicing specified action instance.
43      *
44      * @param implementation action implementation, must not be null
45      * @param instance supported operation identifier. Must not be null.
46      * @return A {@link Registration} object, guaranteed to be non-null.
47      * @throws NullPointerException if any argument is null
48      */
49     default Registration registerActionImplementation(final DOMActionImplementation implementation,
50             final DOMActionInstance instance) {
51         return registerActionImplementation(implementation, ImmutableSet.of(instance));
52     }
53
54     /**
55      * Register an {@link DOMActionImplementation} object with this service, servicing specified action instances.
56      *
57      * @param implementation action implementation, must not be null
58      * @param instances Set of supported operation identifiers. Must not be null, empty, or contain a null element.
59      * @return A {@link Registration} object, guaranteed to be non-null.
60      * @throws NullPointerException if {@code implementation} or {@code instances} is null, or if {@code instances}
61      *                              contains a null element.
62      * @throws IllegalArgumentException if {@code instances} is empty
63      */
64     default Registration registerActionImplementation(final DOMActionImplementation implementation,
65             final DOMActionInstance... instances) {
66         return registerActionImplementation(implementation, ImmutableSet.copyOf(instances));
67     }
68 }