blob: 1889a532d5e999a844822a0efb8271af61404a3c [file] [log] [blame]
Jonathan Hart7d7e2f52016-03-29 16:22:49 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Jonathan Hart7d7e2f52016-03-29 16:22:49 -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 */
16
17package org.onosproject.incubator.net.routing;
18
19import org.onosproject.event.AbstractEvent;
20
Jonathan Hart6c2e7962016-04-11 13:54:09 -070021import java.util.Objects;
22
Jonathan Hart7d7e2f52016-03-29 16:22:49 -070023/**
24 * Describes an event about a route.
25 */
26public class RouteEvent extends AbstractEvent<RouteEvent.Type, ResolvedRoute> {
27
28 /**
29 * Route event type.
30 */
31 public enum Type {
32
33 /**
34 * Route is new.
35 */
36 ROUTE_ADDED,
37
38 /**
39 * Route has updated information.
40 */
41 ROUTE_UPDATED,
42
43 /**
44 * Route was removed.
45 */
46 ROUTE_REMOVED
47 }
48
49 /**
50 * Creates a new route event.
51 *
52 * @param type event type
53 * @param subject event subject
54 */
55 public RouteEvent(Type type, ResolvedRoute subject) {
56 super(type, subject);
57 }
58
59 /**
60 * Creates a new route event.
61 *
62 * @param type event type
63 * @param subject event subject
64 * @param time event time
65 */
66 protected RouteEvent(Type type, ResolvedRoute subject, long time) {
67 super(type, subject, time);
68 }
69
Jonathan Hart6c2e7962016-04-11 13:54:09 -070070 @Override
71 public int hashCode() {
72 return Objects.hash(subject(), type());
73 }
74
75 @Override
76 public boolean equals(Object other) {
77 if (this == other) {
78 return true;
79 }
80
81 if (!(other instanceof RouteEvent)) {
82 return false;
83 }
84
85 RouteEvent that = (RouteEvent) other;
86
87 return Objects.equals(this.subject(), that.subject()) &&
88 Objects.equals(this.type(), that.type());
89 }
Jonathan Hart7d7e2f52016-03-29 16:22:49 -070090}