blob: f3da880b517c7ee65fe34ba558e3ab322bbc43e4 [file] [log] [blame]
Charles Chane849c192016-01-11 18:28:54 -08001/*
2 * Copyright 2015 Open Networking Laboratory
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.grouphandler;
18
19import org.onlab.packet.VlanId;
20import org.onosproject.net.DeviceId;
21
22import java.util.Objects;
23
24/**
25 * Key of VLAN cross-connect next objective store.
26 */
27public class XConnectNextObjectiveStoreKey {
28 private final DeviceId deviceId;
29 private final VlanId vlanId;
30
31 /**
32 * Constructs the key of cross-connect next objective store.
33 *
34 * @param deviceId device ID of the VLAN cross-connection
35 * @param vlanId VLAN ID of the VLAN cross-connection
36 */
37 public XConnectNextObjectiveStoreKey(DeviceId deviceId, VlanId vlanId) {
38 this.deviceId = deviceId;
39 this.vlanId = vlanId;
40 }
41
42 /**
43 * Returns the device ID of this key.
44 *
45 * @return device ID
46 */
47 public DeviceId deviceId() {
48 return this.deviceId;
49 }
50
51 /**
52 * Returns the VLAN ID of this key.
53 *
54 * @return VLAN ID
55 */
56 public VlanId vlanId() {
57 return this.vlanId;
58 }
59
60 @Override
61 public boolean equals(Object o) {
62 if (this == o) {
63 return true;
64 }
65 if (!(o instanceof XConnectNextObjectiveStoreKey)) {
66 return false;
67 }
68 XConnectNextObjectiveStoreKey that =
69 (XConnectNextObjectiveStoreKey) o;
70 return (Objects.equals(this.deviceId, that.deviceId) &&
71 Objects.equals(this.vlanId, that.vlanId));
72 }
73
74 // The list of neighbor ids and label are used for comparison.
75 @Override
76 public int hashCode() {
77 return Objects.hash(deviceId, vlanId);
78 }
79
80 @Override
81 public String toString() {
82 return "Device: " + deviceId + " VlanId: " + vlanId;
83 }
84}