blob: 0e90a229d8c12dff9f628539864bc56e839fb99d [file] [log] [blame]
Charles Chane849c192016-01-11 18:28:54 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Charles Chane849c192016-01-11 18:28:54 -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
Charles Chand2990362016-04-18 13:44:03 -070017package org.onosproject.segmentrouting.storekey;
Charles Chane849c192016-01-11 18:28:54 -080018
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 */
Charles Chanfc5c7802016-05-17 13:13:55 -070027public class XConnectStoreKey {
Charles Chane849c192016-01-11 18:28:54 -080028 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 */
Charles Chanfc5c7802016-05-17 13:13:55 -070037 public XConnectStoreKey(DeviceId deviceId, VlanId vlanId) {
Charles Chane849c192016-01-11 18:28:54 -080038 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 }
Charles Chanfc5c7802016-05-17 13:13:55 -070065 if (!(o instanceof XConnectStoreKey)) {
Charles Chane849c192016-01-11 18:28:54 -080066 return false;
67 }
Charles Chanfc5c7802016-05-17 13:13:55 -070068 XConnectStoreKey that =
69 (XConnectStoreKey) o;
Charles Chane849c192016-01-11 18:28:54 -080070 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}