blob: 1bcddafba4cc70243adb24fbfe1de108edb20c95 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.topology;
tomedf06bb2014-08-27 16:22:15 -070017
Brian O'Connorabafb502014-12-02 22:26:20 -080018import org.onosproject.event.AbstractEvent;
19import org.onosproject.event.Event;
tom95329eb2014-10-06 08:40:06 -070020
21import java.util.List;
tomedf06bb2014-08-27 16:22:15 -070022
23/**
24 * Describes network topology event.
25 */
26public class TopologyEvent extends AbstractEvent<TopologyEvent.Type, Topology> {
27
tom95329eb2014-10-06 08:40:06 -070028 private final List<Event> reasons;
29
tomedf06bb2014-08-27 16:22:15 -070030 /**
31 * Type of topology events.
32 */
33 public enum Type {
34 /**
35 * Signifies that topology has changed.
36 */
37 TOPOLOGY_CHANGED
38 }
39
40 /**
41 * Creates an event of a given type and for the specified topology and the
42 * current time.
43 *
44 * @param type topology event type
45 * @param topology event topology subject
tom95329eb2014-10-06 08:40:06 -070046 * @param reasons list of events that triggered topology change
tomedf06bb2014-08-27 16:22:15 -070047 */
tom95329eb2014-10-06 08:40:06 -070048 public TopologyEvent(Type type, Topology topology, List<Event> reasons) {
tomedf06bb2014-08-27 16:22:15 -070049 super(type, topology);
tom95329eb2014-10-06 08:40:06 -070050 this.reasons = reasons;
tomedf06bb2014-08-27 16:22:15 -070051 }
52
53 /**
54 * Creates an event of a given type and for the specified topology and time.
55 *
56 * @param type link event type
57 * @param topology event topology subject
tom95329eb2014-10-06 08:40:06 -070058 * @param reasons list of events that triggered topology change
tomedf06bb2014-08-27 16:22:15 -070059 * @param time occurrence time
60 */
tom95329eb2014-10-06 08:40:06 -070061 public TopologyEvent(Type type, Topology topology, List<Event> reasons,
62 long time) {
tomedf06bb2014-08-27 16:22:15 -070063 super(type, topology, time);
tom95329eb2014-10-06 08:40:06 -070064 this.reasons = reasons;
65 }
66
67
68 /**
69 * Returns the list of events that triggered the topology change.
70 *
71 * @return list of events responsible for change in topology; null if
72 * initial topology computation
73 */
74 public List<Event> reasons() {
75 return reasons;
tomedf06bb2014-08-27 16:22:15 -070076 }
77
78}