blob: 18ce018194857a6971089eb50ec58553e8ad34e8 [file] [log] [blame]
William Davies5bae5052019-10-19 01:25:01 -07001/*
2 * Copyright 2017-present Open Networking Foundation
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.routing.fpm;
18
19import java.util.Objects;
20
21import static com.google.common.base.MoreObjects.toStringHelper;
22
23/**
24 * Represents an FPM peer with accept routes flag.
25 */
26public class FpmPeerAcceptRoutes {
27
28 private final boolean isAcceptRoutes;
29 private final FpmPeer peer;
30
31
32
33 /**
34 * Creates a new FPM peer.
35 *
36 * @param peer Fpm Peer
37 * @param isAcceptRoutes is route accepted on peer
38 *
39 */
40 public FpmPeerAcceptRoutes(FpmPeer peer, boolean isAcceptRoutes) {
41 this.peer = peer;
42 this.isAcceptRoutes = isAcceptRoutes;
43 }
44
45 /**
46 * Returns isAcceptRoutes flag status.
47 *
48 * @return isAcceptRoutes
49 */
50 public boolean isAcceptRoutes() {
51 return isAcceptRoutes;
52 }
53
54 /**
55 * Returns the FPM peer.
56 *
57 * @return FPM peer
58 */
59 public FpmPeer peer() {
60 return peer;
61 }
62
63 @Override
64 public int hashCode() {
65 return Objects.hash(isAcceptRoutes, peer);
66 }
67
68 @Override
69 public boolean equals(Object other) {
70 if (this == other) {
71 return true;
72 }
73
74 if (!(other instanceof FpmPeerAcceptRoutes)) {
75 return false;
76 }
77
78 FpmPeerAcceptRoutes that = (FpmPeerAcceptRoutes) other;
79
80 return Objects.equals(this.isAcceptRoutes, that.isAcceptRoutes) &&
81 Objects.equals(this.peer, that.peer);
82 }
83
84 @Override
85 public String toString() {
86 return toStringHelper(this)
87 .add("peer", peer)
88 .add("isAcceptRoutes", isAcceptRoutes)
89 .toString();
90 }
91
92}