blob: 5448b882f20b63681e40fa3d292351faad9101b5 [file] [log] [blame]
Simon Huntcda9c032016-04-11 10:32:54 -07001/*
Thomas Vachuska8c0b18a2017-04-14 16:27:33 -07002 * Copyright 2017-present Open Networking Laboratory
Simon Huntcda9c032016-04-11 10:32:54 -07003 *
Thomas Vachuska8c0b18a2017-04-14 16:27:33 -07004 * 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
Simon Huntcda9c032016-04-11 10:32:54 -07007 *
Thomas Vachuska8c0b18a2017-04-14 16:27:33 -07008 * http://www.apache.org/licenses/LICENSE-2.0
Simon Huntcda9c032016-04-11 10:32:54 -07009 *
Thomas Vachuska8c0b18a2017-04-14 16:27:33 -070010 * 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.
Simon Huntcda9c032016-04-11 10:32:54 -070015 */
16
Thomas Vachuska8c0b18a2017-04-14 16:27:33 -070017package org.onosproject.ui.model.topo;
Simon Huntcda9c032016-04-11 10:32:54 -070018
Simon Hunt8eac4ae2017-01-20 12:56:45 -080019import com.fasterxml.jackson.databind.node.ObjectNode;
Simon Huntcda9c032016-04-11 10:32:54 -070020import org.onosproject.event.AbstractEvent;
Simon Huntcda9c032016-04-11 10:32:54 -070021
22/**
23 * UI Topology model events.
24 */
25public class UiModelEvent extends AbstractEvent<UiModelEvent.Type, UiElement> {
26
Simon Hunt8eac4ae2017-01-20 12:56:45 -080027 /**
28 * Enumeration of event types.
29 */
Thomas Vachuska8c0b18a2017-04-14 16:27:33 -070030 public enum Type {
Simon Hunt642bc452016-05-04 19:34:45 -070031 CLUSTER_MEMBER_ADDED_OR_UPDATED,
32 CLUSTER_MEMBER_REMOVED,
33
Simon Huntc0f20c12016-05-09 09:30:20 -070034 REGION_ADDED_OR_UPDATED,
35 REGION_REMOVED,
36
Simon Hunt642bc452016-05-04 19:34:45 -070037 DEVICE_ADDED_OR_UPDATED,
Simon Huntcda9c032016-04-11 10:32:54 -070038 DEVICE_REMOVED,
Simon Hunt642bc452016-05-04 19:34:45 -070039
Simon Huntc0f20c12016-05-09 09:30:20 -070040 LINK_ADDED_OR_UPDATED,
41 LINK_REMOVED,
42
43 HOST_ADDED_OR_UPDATED,
44 HOST_MOVED,
45 HOST_REMOVED
Simon Huntcda9c032016-04-11 10:32:54 -070046 }
Simon Hunt8eac4ae2017-01-20 12:56:45 -080047
48 private final ObjectNode data;
49 private final String memo;
50
51 /**
52 * Creates a UI model event. Note that the memo field can be used to
53 * pass a hint to the listener about the event.
54 *
55 * @param type event type
56 * @param subject subject of the event
57 * @param data data containing details of the subject
58 * @param memo a note about the event
59 */
Thomas Vachuska8c0b18a2017-04-14 16:27:33 -070060 public UiModelEvent(Type type, UiElement subject, ObjectNode data,
61 String memo) {
Simon Hunt8eac4ae2017-01-20 12:56:45 -080062 super(type, subject);
63 this.data = data;
64 this.memo = memo;
65 }
66
67 /**
68 * Returns the data of the subject.
69 *
70 * @return the subject data
71 */
72 public ObjectNode data() {
73 return data;
74 }
75
76 /**
77 * Returns the memo.
78 *
79 * @return the memo
80 */
81 public String memo() {
82 return memo;
83 }
84
Simon Huntcda9c032016-04-11 10:32:54 -070085}