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