blob: 9439145cd7d584cc549a21241325cfd8794c2f68 [file] [log] [blame]
alshabib1d2bc402015-07-31 17:04:11 -07001/*
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 */
16package org.onosproject.incubator.net.meter;
17
18import org.onosproject.event.AbstractEvent;
19
20/**
21 * Entity that represents Meter events.
22 */
alshabib7bb05012015-08-05 10:15:09 -070023public class MeterEvent extends AbstractEvent<MeterEvent.Type, MeterOperation> {
alshabib1d2bc402015-07-31 17:04:11 -070024
25
alshabib7bb05012015-08-05 10:15:09 -070026 private final MeterFailReason reason;
alshabib1d2bc402015-07-31 17:04:11 -070027
alshabib7bb05012015-08-05 10:15:09 -070028 public enum Type {
alshabib1d2bc402015-07-31 17:04:11 -070029
30 /**
31 * Signals that a meter has been added.
32 */
33 METER_UPDATED,
34
35 /**
alshabib1d2bc402015-07-31 17:04:11 -070036 * Signals that a meter update failed.
37 */
alshabib7bb05012015-08-05 10:15:09 -070038 METER_OP_FAILED,
39
40 /**
41 * A meter operation was requested.
42 */
43 METER_OP_REQ,
44
alshabib1d2bc402015-07-31 17:04:11 -070045 }
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
alshabib7bb05012015-08-05 10:15:09 -070053 * @param op event subject
alshabib1d2bc402015-07-31 17:04:11 -070054 */
alshabib7bb05012015-08-05 10:15:09 -070055 public MeterEvent(Type type, MeterOperation op) {
56 super(type, op);
57 this.reason = null;
alshabib1d2bc402015-07-31 17:04:11 -070058 }
59
60 /**
61 * Creates an event of a given type and for the specified meter and time.
62 *
63 * @param type meter event type
alshabib7bb05012015-08-05 10:15:09 -070064 * @param op event subject
alshabib1d2bc402015-07-31 17:04:11 -070065 * @param time occurrence time
66 */
alshabib7bb05012015-08-05 10:15:09 -070067 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;
alshabib1d2bc402015-07-31 17:04:11 -070079 }
80
81}