blob: 8ca57f22f29868b428abbb74d333511b07c56676 [file] [log] [blame]
alshabiba9b2b5d2015-09-23 15:01:47 -07001/*
2 * Copyright 2015 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 */
16package org.onosproject.mcast;
17
18import org.onosproject.event.AbstractEvent;
19import org.onosproject.net.ConnectPoint;
20
21import java.util.Optional;
22
23/**
24 * An entity representing a multicast event. Event either add or remove
25 * sinks or sources.
26 */
27public class McastEvent extends AbstractEvent<McastEvent.Type, McastRoute> {
28
29 private final Optional<ConnectPoint> sink;
30 private final Optional<ConnectPoint> source;
31
32 public enum Type {
33 /**
34 * A new mcast route has been added.
35 */
36 ROUTE_ADDED,
37
38 /**
39 * A mcast route has been removed.
40 */
41 ROUTE_REMOVED,
42
43 /**
44 * A source for a mcast route (ie. the subject) has been added.
45 */
46 SOURCE_ADDED,
47
48 /**
49 * A source for a mcast route (ie. the subject) has been removed.
50 */
51 SOURCE_REMOVED,
52
53 /**
54 * A sink for a mcast route (ie. the subject) has been added.
55 */
56 SINK_ADDED,
57
58 /**
59 * A source for a mcast route (ie. the subject) has been removed.
60 */
61 SINK_REMOVED
62 }
63
64 private McastEvent(McastEvent.Type type, McastRoute subject) {
65 super(type, subject);
66 sink = Optional.empty();
67 source = Optional.empty();
68 }
69
70 private McastEvent(McastEvent.Type type, McastRoute subject, long time) {
71 super(type, subject, time);
72 sink = Optional.empty();
73 source = Optional.empty();
74 }
75
76 protected McastEvent(McastEvent.Type type, McastRoute subject,
77 ConnectPoint sink,
78 ConnectPoint source) {
79 super(type, subject);
80 this.sink = Optional.ofNullable(sink);
81 this.source = Optional.ofNullable(source);
82 }
83
84 protected McastEvent(McastEvent.Type type, McastRoute subject, long time,
85 ConnectPoint sink,
86 ConnectPoint source) {
87 super(type, subject, time);
88 this.sink = Optional.ofNullable(sink);
89 this.source = Optional.ofNullable(source);
90 }
91
92 /**
93 * The sink which has been removed or added. The field may not be set
94 * if the sink has not been detected yet or has been removed.
95 *
96 * @return an optional connect point
97 */
98 public Optional<ConnectPoint> sink() {
99 return sink;
100 }
101
102 /**
103 * The source which has been removed or added. The field may not be set
104 * if the source has not been detected yet or has been removed.
105
106 * @return an optional connect point
107 */
108 public Optional<ConnectPoint> source() {
109 return source;
110 }
111}