blob: 6d6998495a1019c4dc1e9d79cd6e15807a747219 [file] [log] [blame]
Harshada Chaundkar9204f312019-07-02 16:01:24 +00001/*
2 * Copyright 2018-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.segmentrouting.mcast;
18
19import org.onlab.packet.VlanId;
20import org.onosproject.net.ConnectPoint;
21
22import java.util.Objects;
23
24import static com.google.common.base.MoreObjects.toStringHelper;
25import static com.google.common.base.Preconditions.checkNotNull;
26
27/**
28 * Key of multicast filtering objective store.
29 */
30public class McastFilteringObjStoreKey {
31
32 private final ConnectPoint ingressCP;
33 private final VlanId vlanId;
34 private final boolean isIpv4;
35
36 /**
37 * Constructs the key of multicast filtering objective store.
38 *
39 * @param ingressCP ingress ConnectPoint
40 * @param vlanId vlan id
41 * @param isIpv4 is Ipv4
42 */
43 public McastFilteringObjStoreKey(ConnectPoint ingressCP, VlanId vlanId, boolean isIpv4) {
44 checkNotNull(ingressCP, "connectpoint cannot be null");
45 checkNotNull(vlanId, "vlanid cannot be null");
46 this.ingressCP = ingressCP;
47 this.vlanId = vlanId;
48 this.isIpv4 = isIpv4;
49 }
50
51 // Constructor for serialization
52 private McastFilteringObjStoreKey() {
53 this.ingressCP = null;
54 this.vlanId = null;
55 this.isIpv4 = false;
56 }
57
58
59 /**
60 * Returns the connect point.
61 *
62 * @return ingress connectpoint
63 */
64 public ConnectPoint ingressCP() {
65 return ingressCP;
66 }
67
68 /**
69 * Returns whether the filtering is for ipv4 mcast.
70 *
71 * @return isIpv4
72 */
73 public boolean isIpv4() {
74 return isIpv4;
75 }
76
77 /**
78 * Returns the vlan ID of this key.
79 *
80 * @return vlan ID
81 */
82 public VlanId vlanId() {
83 return vlanId;
84 }
85
86 @Override
87 public boolean equals(Object o) {
88 if (this == o) {
89 return true;
90 }
91 if (!(o instanceof McastFilteringObjStoreKey)) {
92 return false;
93 }
94 McastFilteringObjStoreKey that =
95 (McastFilteringObjStoreKey) o;
96 return (Objects.equals(this.ingressCP, that.ingressCP) &&
97 Objects.equals(this.isIpv4, that.isIpv4) &&
98 Objects.equals(this.vlanId, that.vlanId));
99 }
100
101 @Override
102 public int hashCode() {
103 return Objects.hash(ingressCP, vlanId, isIpv4);
104 }
105
106 @Override
107 public String toString() {
108 return toStringHelper(getClass())
109 .add("ingressCP", ingressCP)
110 .add("isIpv4", isIpv4)
111 .add("vlanId", vlanId)
112 .toString();
113 }
114}