Carmelo Cascone | 75a9a89 | 2019-04-22 12:12:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.net.pi.service; |
| 18 | |
| 19 | import org.onosproject.event.AbstractEvent; |
| 20 | import org.onosproject.net.pi.model.PiPipeconf; |
| 21 | import org.onosproject.net.pi.model.PiPipeconfId; |
| 22 | |
| 23 | import static com.google.common.base.Preconditions.checkNotNull; |
| 24 | |
| 25 | /** |
| 26 | * Event related to the PiPipeconfService. |
| 27 | */ |
| 28 | public class PiPipeconfEvent extends AbstractEvent<PiPipeconfEvent.Type, PiPipeconfId> { |
| 29 | |
| 30 | private final PiPipeconf pipeconf; |
| 31 | |
| 32 | /** |
| 33 | * Type of pipeconf event. |
| 34 | */ |
| 35 | public enum Type { |
| 36 | REGISTERED, |
| 37 | UNREGISTERED |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Creates anew pipeconf event for the given type and pipeconf. |
| 42 | * |
| 43 | * @param type type of event |
| 44 | * @param pipeconf pipeconf |
| 45 | */ |
| 46 | public PiPipeconfEvent(Type type, PiPipeconf pipeconf) { |
| 47 | super(type, checkNotNull(pipeconf).id()); |
| 48 | this.pipeconf = pipeconf; |
| 49 | } |
| 50 | |
| 51 | |
| 52 | /** |
| 53 | * Creates anew pipeconf event for the given type and pipeconf ID. |
| 54 | * |
| 55 | * @param type type of event |
| 56 | * @param pipeconfId pipeconf ID |
| 57 | */ |
| 58 | public PiPipeconfEvent(Type type, PiPipeconfId pipeconfId) { |
| 59 | super(type, pipeconfId); |
| 60 | pipeconf = null; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Returns the pipeconf instance associated to this event, or null if one |
| 65 | * was not provided. For example, {@link Type#UNREGISTERED} events are not |
| 66 | * expected to carry the pipeconf instance that was unregistered, but just |
| 67 | * the ID (via {@link #subject()}). |
| 68 | * |
| 69 | * @return pipeconf instance or null |
| 70 | */ |
| 71 | public PiPipeconf pipeconf() { |
| 72 | return pipeconf; |
| 73 | } |
| 74 | } |