blob: 238ede417e9272b6e460871a2c497af8b5a97ab7 [file] [log] [blame]
Thomas Vachuskae6a57412017-08-23 14:09:14 -07001/*
2 * Copyright 2017-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
17package org.onosproject.net.driver;
18
19import org.joda.time.LocalDateTime;
20import org.onosproject.event.AbstractEvent;
21
22import static com.google.common.base.MoreObjects.toStringHelper;
23
24/**
25 * Driver configuration change event.
26 */
27public class DriverEvent extends AbstractEvent<DriverEvent.Type, Driver> {
28
29 /**
30 * Type of driver events.
31 */
32 public enum Type {
33 /**
34 * Signifies that the driver configuration has changed in an additive
35 * manner. Either new behaviours were added, their implementations
36 * changed, or there is a new driver entirely.
37 */
38 DRIVER_ENHANCED,
39
40 /**
41 * Signifies that the driver configuration has been reduced in some way.
42 * Either behaviours or their implementations were withdrawn or the
43 * driver was removed entirely.
44 */
45 DRIVER_REDUCED
46 }
47
48 /**
49 * Creates an event of a given type and for the specified driver and the
50 * current time.
51 *
52 * @param type device event type
53 * @param driver event driver subject
54 */
55 public DriverEvent(Type type, Driver driver) {
56 super(type, driver);
57 }
58
59 /**
60 * Creates an event of a given type and for the specified driver and time.
61 *
62 * @param type device event type
63 * @param driver event driver subject
64 * @param time occurrence time
65 */
66 public DriverEvent(Type type, Driver driver, long time) {
67 super(type, driver, time);
68 }
69
70 @Override
71 public String toString() {
72 return toStringHelper(this)
73 .add("time", new LocalDateTime(time()))
74 .add("type", type())
75 .add("subject", subject())
76 .toString();
77 }
78}