alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 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 | package org.onosproject.incubator.net.meter; |
| 17 | |
| 18 | import org.onosproject.event.AbstractEvent; |
| 19 | |
| 20 | /** |
| 21 | * Entity that represents Meter events. |
| 22 | */ |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 23 | public class MeterEvent extends AbstractEvent<MeterEvent.Type, MeterOperation> { |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 24 | |
| 25 | |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 26 | private final MeterFailReason reason; |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 27 | |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 28 | public enum Type { |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * Signals that a meter has been added. |
| 32 | */ |
| 33 | METER_UPDATED, |
| 34 | |
| 35 | /** |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 36 | * Signals that a meter update failed. |
| 37 | */ |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 38 | METER_OP_FAILED, |
| 39 | |
| 40 | /** |
| 41 | * A meter operation was requested. |
| 42 | */ |
| 43 | METER_OP_REQ, |
| 44 | |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | |
| 48 | /** |
| 49 | * Creates an event of a given type and for the specified meter and the |
| 50 | * current time. |
| 51 | * |
| 52 | * @param type meter event type |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 53 | * @param op event subject |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 54 | */ |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 55 | public MeterEvent(Type type, MeterOperation op) { |
| 56 | super(type, op); |
| 57 | this.reason = null; |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Creates an event of a given type and for the specified meter and time. |
| 62 | * |
| 63 | * @param type meter event type |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 64 | * @param op event subject |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 65 | * @param time occurrence time |
| 66 | */ |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 67 | public MeterEvent(Type type, MeterOperation op, long time) { |
| 68 | super(type, op, time); |
| 69 | this.reason = null; |
| 70 | } |
| 71 | |
| 72 | public MeterEvent(Type type, MeterOperation op, MeterFailReason reason) { |
| 73 | super(type, op); |
| 74 | this.reason = reason; |
| 75 | } |
| 76 | |
| 77 | public MeterFailReason reason() { |
| 78 | return reason; |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | } |