blob: 6f0abd8c12c16c94bc71b1de2f2037c8b191871c [file] [log] [blame]
Thomas Vachuska48448082016-02-19 22:14:54 -08001/*
2 * Copyright 2016 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 */
16
17package org.onosproject.net.region;
18
19import com.google.common.collect.ImmutableSet;
20import org.onosproject.event.AbstractEvent;
21import org.onosproject.net.DeviceId;
22
23import java.util.Set;
24
25/**
26 * Describes region event.
27 */
28public class RegionEvent extends AbstractEvent<RegionEvent.Type, Region> {
29
30 private final Set<DeviceId> deviceIds;
31
32 public enum Type {
33 /**
34 * Signifies that a new region was created.
35 */
36 REGION_ADDED,
37
38 /**
39 * Signifies that a region was updated.
40 */
41 REGION_REMOVED,
42
43 /**
44 * Signifies that a region was removed.
45 */
46 REGION_UPDATED,
47
48 /**
49 * Signifies that a region device membership has changed.
50 */
51 REGION_MEMBERSHIP_CHANGED
52 }
53
54 /**
55 * Creates an event of a given type and for the specified region and the
56 * current time.
57 *
58 * @param type device event type
59 * @param region event region subject
60 */
61 public RegionEvent(Type type, Region region) {
62 this(type, region, null);
63 }
64
65 /**
66 * Creates an event of a given type and for the specified region, device
67 * id list and the current time.
68 *
69 * @param type device event type
70 * @param region event region subject
71 * @param deviceIds optional set of device ids
72 */
73 public RegionEvent(Type type, Region region, Set<DeviceId> deviceIds) {
74 super(type, region);
75 this.deviceIds = deviceIds != null ? ImmutableSet.copyOf(deviceIds) : ImmutableSet.of();
76 }
77
78 /**
79 * Creates an event of a given type and for the specified device and time.
80 *
81 * @param type device event type
82 * @param region event region subject
83 * @param deviceIds optional set of device ids
84 * @param time occurrence time
85 */
86 public RegionEvent(Type type, Region region, Set<DeviceId> deviceIds, long time) {
87 super(type, region, time);
88 this.deviceIds = deviceIds != null ? ImmutableSet.copyOf(deviceIds) : ImmutableSet.of();
89 }
90
91}