blob: 4a1ab7854973955d71cb4f77bb223fc5f53ae5a9 [file] [log] [blame]
Ruchi Sahotaef0761c2019-01-28 01:08:18 +00001/*
2 * Copyright 2019-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 */
16package org.onosproject.segmentrouting.storekey;
17
18import org.onlab.packet.VlanId;
19import org.onlab.packet.MacAddress;
20import org.onosproject.net.DeviceId;
21
22import java.util.Objects;
23
24import static com.google.common.base.MoreObjects.toStringHelper;
25
26/**
27 * Key of Device/Vlan/MacAddr to NextObjective store.
28 */
29public class MacVlanNextObjectiveStoreKey {
30 private final DeviceId deviceId;
31 private final MacAddress macAddr;
32 private final VlanId vlanId;
33
34 /**
35 * Constructs the key of the next objective store.
36 *
37 * @param deviceId device ID
38 * @param macAddr mac of host
39 * @param vlanId vlan of host
40 */
41 public MacVlanNextObjectiveStoreKey(DeviceId deviceId, MacAddress macAddr, VlanId vlanId) {
42 this.deviceId = deviceId;
43 this.macAddr = macAddr;
44 this.vlanId = vlanId;
45 }
46
47 /**
48 * Gets device id in this MacVlanNextObjectiveStoreKey.
49 *
50 * @return device id
51 */
52 public DeviceId deviceId() {
53 return deviceId;
54 }
55
56 /**
57 * Gets vlan information in this MacVlanNextObjectiveStoreKey.
58 *
59 * @return vlan information
60 */
61 public VlanId vlanId() {
62 return vlanId;
63 }
64
65 /**
66 * Gets mac information in this MacVlanNextObjectiveStoreKey.
67 *
68 * @return mac information
69 */
70 public MacAddress macAddr() {
71 return macAddr;
72 }
73
74 @Override
75 public boolean equals(Object o) {
76 if (this == o) {
77 return true;
78 }
79 if (!(o instanceof MacVlanNextObjectiveStoreKey)) {
80 return false;
81 }
82 MacVlanNextObjectiveStoreKey that =
83 (MacVlanNextObjectiveStoreKey) o;
84 return (Objects.equals(this.deviceId, that.deviceId) &&
85 Objects.equals(this.vlanId, that.vlanId) &&
86 Objects.equals(this.macAddr, that.macAddr));
87 }
88
89 @Override
90 public int hashCode() {
91 return Objects.hash(deviceId, vlanId, macAddr);
92 }
93
94 @Override
95 public String toString() {
96 return toStringHelper(getClass())
97 .add("deviceId", deviceId)
98 .add("vlanId", vlanId)
99 .add("macAddr", macAddr)
100 .toString();
101 }
102}