blob: d8acae7fb10c07791a1b4b274d731e8014664340 [file] [log] [blame]
Jonathan Hart552e31f2015-02-06 11:11:59 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Jonathan Hart552e31f2015-02-06 11:11:59 -08003 *
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 */
Jonathan Hart2da1e602015-02-18 19:09:24 -080016package org.onosproject.routing;
Jonathan Hart41349e92015-02-09 14:14:02 -080017
18import com.google.common.base.MoreObjects;
19
20import java.util.Objects;
Jonathan Hart552e31f2015-02-06 11:11:59 -080021
22/**
23 * Represents a change to the Forwarding Information Base (FIB).
Jonathan Hart888eaa02016-06-22 15:56:21 -070024 *
25 * @deprecated use RouteService instead
Jonathan Hart552e31f2015-02-06 11:11:59 -080026 */
Jonathan Hart888eaa02016-06-22 15:56:21 -070027@Deprecated
Jonathan Hart552e31f2015-02-06 11:11:59 -080028public class FibUpdate {
29
30 /**
31 * Specifies the type of the FIB update.
32 */
33 public enum Type {
34 /**
35 * The update contains a new or updated FIB entry for a prefix.
36 */
37 UPDATE,
38
39 /**
40 * The update signals that a prefix should be removed from the FIB.
41 */
42 DELETE
43 }
44
45 private final Type type;
46 private final FibEntry entry;
47
48 /**
49 * Creates a new FIB update.
50 *
51 * @param type type of the update
52 * @param entry FIB entry describing the update
53 */
54 public FibUpdate(Type type, FibEntry entry) {
55 this.type = type;
56 this.entry = entry;
57 }
58
59 /**
60 * Returns the type of the update.
61 *
62 * @return update type
63 */
64 public Type type() {
65 return type;
66 }
67
68 /**
69 * Returns the FIB entry which contains update information.
70 *
71 * @return the FIB entry
72 */
73 public FibEntry entry() {
74 return entry;
75 }
Jonathan Hart41349e92015-02-09 14:14:02 -080076
77 @Override
78 public boolean equals(Object o) {
79 if (!(o instanceof FibUpdate)) {
80 return false;
81 }
82
83 FibUpdate that = (FibUpdate) o;
84
85 return Objects.equals(this.type, that.type) &&
86 Objects.equals(this.entry, that.entry);
87 }
88
89 @Override
90 public int hashCode() {
91 return Objects.hash(type, entry);
92 }
93
94 @Override
95 public String toString() {
96 return MoreObjects.toStringHelper(getClass())
97 .add("type", type)
98 .add("entry", entry)
99 .toString();
100 }
Jonathan Hart552e31f2015-02-06 11:11:59 -0800101}