Carmelo Cascone | e5b2872 | 2018-06-22 17:28:28 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-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.p4runtime.ctl; |
| 18 | |
| 19 | import org.onosproject.net.DeviceId; |
| 20 | import org.onosproject.p4runtime.api.P4RuntimeEventSubject; |
| 21 | |
| 22 | /** |
| 23 | * Channel event in P4Runtime. |
| 24 | */ |
| 25 | final class ChannelEvent implements P4RuntimeEventSubject { |
| 26 | |
| 27 | enum Type { |
| 28 | OPEN, |
| 29 | CLOSED, |
| 30 | ERROR |
| 31 | } |
| 32 | |
| 33 | private DeviceId deviceId; |
| 34 | private Type type; |
| 35 | |
| 36 | /** |
| 37 | * Creates channel event with given status and throwable. |
| 38 | * |
| 39 | * @param deviceId the device |
| 40 | * @param type error type |
| 41 | */ |
| 42 | ChannelEvent(DeviceId deviceId, Type type) { |
| 43 | this.deviceId = deviceId; |
| 44 | this.type = type; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Gets the type of this event. |
| 49 | * |
| 50 | * @return the error type |
| 51 | */ |
| 52 | public Type type() { |
| 53 | return type; |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public DeviceId deviceId() { |
| 58 | return deviceId; |
| 59 | } |
| 60 | } |