Simon Hunt | cda9c03 | 2016-04-11 10:32:54 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Simon Hunt | cda9c03 | 2016-04-11 10:32:54 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 8c0b18a | 2017-04-14 16:27:33 -0700 | [diff] [blame] | 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 |
Simon Hunt | cda9c03 | 2016-04-11 10:32:54 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 8c0b18a | 2017-04-14 16:27:33 -0700 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Simon Hunt | cda9c03 | 2016-04-11 10:32:54 -0700 | [diff] [blame] | 9 | * |
Thomas Vachuska | 8c0b18a | 2017-04-14 16:27:33 -0700 | [diff] [blame] | 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. |
Simon Hunt | cda9c03 | 2016-04-11 10:32:54 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
Thomas Vachuska | 8c0b18a | 2017-04-14 16:27:33 -0700 | [diff] [blame] | 17 | package org.onosproject.ui.model.topo; |
Simon Hunt | cda9c03 | 2016-04-11 10:32:54 -0700 | [diff] [blame] | 18 | |
Simon Hunt | 8eac4ae | 2017-01-20 12:56:45 -0800 | [diff] [blame] | 19 | import com.fasterxml.jackson.databind.node.ObjectNode; |
Simon Hunt | cda9c03 | 2016-04-11 10:32:54 -0700 | [diff] [blame] | 20 | import org.onosproject.event.AbstractEvent; |
Simon Hunt | cda9c03 | 2016-04-11 10:32:54 -0700 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * UI Topology model events. |
| 24 | */ |
| 25 | public class UiModelEvent extends AbstractEvent<UiModelEvent.Type, UiElement> { |
| 26 | |
Simon Hunt | 8eac4ae | 2017-01-20 12:56:45 -0800 | [diff] [blame] | 27 | /** |
| 28 | * Enumeration of event types. |
| 29 | */ |
Thomas Vachuska | 8c0b18a | 2017-04-14 16:27:33 -0700 | [diff] [blame] | 30 | public enum Type { |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 31 | CLUSTER_MEMBER_ADDED_OR_UPDATED, |
| 32 | CLUSTER_MEMBER_REMOVED, |
| 33 | |
Simon Hunt | c0f20c1 | 2016-05-09 09:30:20 -0700 | [diff] [blame] | 34 | REGION_ADDED_OR_UPDATED, |
| 35 | REGION_REMOVED, |
| 36 | |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 37 | DEVICE_ADDED_OR_UPDATED, |
Simon Hunt | cda9c03 | 2016-04-11 10:32:54 -0700 | [diff] [blame] | 38 | DEVICE_REMOVED, |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 39 | |
Simon Hunt | c0f20c1 | 2016-05-09 09:30:20 -0700 | [diff] [blame] | 40 | LINK_ADDED_OR_UPDATED, |
| 41 | LINK_REMOVED, |
| 42 | |
| 43 | HOST_ADDED_OR_UPDATED, |
| 44 | HOST_MOVED, |
| 45 | HOST_REMOVED |
Simon Hunt | cda9c03 | 2016-04-11 10:32:54 -0700 | [diff] [blame] | 46 | } |
Simon Hunt | 8eac4ae | 2017-01-20 12:56:45 -0800 | [diff] [blame] | 47 | |
| 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 Vachuska | 8c0b18a | 2017-04-14 16:27:33 -0700 | [diff] [blame] | 60 | public UiModelEvent(Type type, UiElement subject, ObjectNode data, |
| 61 | String memo) { |
Simon Hunt | 8eac4ae | 2017-01-20 12:56:45 -0800 | [diff] [blame] | 62 | 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 Hunt | cda9c03 | 2016-04-11 10:32:54 -0700 | [diff] [blame] | 85 | } |