blob: 55a95cd07f9db66e93e23ebfcd9b041704e5d886 [file] [log] [blame]
Charles Chan10b0fb72017-02-02 16:20:42 -08001/*
Brian O'Connor0947d7e2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Charles Chan10b0fb72017-02-02 16:20:42 -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 */
16
17package org.onosproject.segmentrouting.storekey;
18
19import org.onlab.packet.VlanId;
20import org.onosproject.net.DeviceId;
21
22import java.util.Objects;
23
Ruchi Sahota71bcb4e2019-01-28 01:08:18 +000024import static com.google.common.base.MoreObjects.toStringHelper;
25
Charles Chan10b0fb72017-02-02 16:20:42 -080026/**
27 * Key of VLAN to NextObjective store.
28 */
29public class VlanNextObjectiveStoreKey {
30 private final DeviceId deviceId;
31 private final VlanId vlanId;
32
33 /**
34 * Constructs the key of VLAN next objective store.
35 *
36 * @param deviceId device ID
37 * @param vlanId VLAN information
38 */
39 public VlanNextObjectiveStoreKey(DeviceId deviceId,
40 VlanId vlanId) {
41 this.deviceId = deviceId;
42 this.vlanId = vlanId;
43 }
44
45 /**
46 * Gets device id in this VlanNextObjectiveStoreKey.
47 *
48 * @return device id
49 */
50 public DeviceId deviceId() {
51 return this.deviceId;
52 }
53
54 /**
55 * Gets vlan information in this VlanNextObjectiveStoreKey.
56 *
57 * @return vlan id
58 */
59 public VlanId vlanId() {
60 return this.vlanId;
61 }
62
63 @Override
64 public boolean equals(Object o) {
65 if (this == o) {
66 return true;
67 }
68 if (!(o instanceof VlanNextObjectiveStoreKey)) {
69 return false;
70 }
71 VlanNextObjectiveStoreKey that =
72 (VlanNextObjectiveStoreKey) o;
73 return (Objects.equals(this.deviceId, that.deviceId) &&
74 Objects.equals(this.vlanId, that.vlanId));
75 }
76
77 @Override
78 public int hashCode() {
79 return Objects.hash(deviceId, vlanId);
80 }
81
82 @Override
83 public String toString() {
Ruchi Sahota71bcb4e2019-01-28 01:08:18 +000084 return toStringHelper(getClass())
85 .add("deviceId", deviceId)
86 .add("vlanId", vlanId)
87 .toString();
Charles Chan10b0fb72017-02-02 16:20:42 -080088 }
89}