blob: 8cd104e178a910c89ec02162a4f58942f4366df6 [file] [log] [blame]
Brian O'Connor7cbbbb72016-04-09 02:13:23 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Brian O'Connor7cbbbb72016-04-09 02:13:23 -07003 *
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 */
Charles Chand2990362016-04-18 13:44:03 -070016package org.onosproject.segmentrouting.storekey;
Saurav Das0e99e2b2015-10-28 12:39:42 -070017
Pier Ventre10bd8d12016-11-26 21:05:22 -080018import org.onlab.packet.IpPrefix;
Saurav Das0e99e2b2015-10-28 12:39:42 -070019import org.onosproject.net.DeviceId;
20
Pier Ventre10bd8d12016-11-26 21:05:22 -080021import java.util.Objects;
22
Saurav Das0e99e2b2015-10-28 12:39:42 -070023/**
Charles Chane849c192016-01-11 18:28:54 -080024 * Key of assigned VLAN ID store.
Saurav Das0e99e2b2015-10-28 12:39:42 -070025 */
26public class SubnetAssignedVidStoreKey {
27 private final DeviceId deviceId;
Pier Ventre10bd8d12016-11-26 21:05:22 -080028 private final IpPrefix subnet;
Saurav Das0e99e2b2015-10-28 12:39:42 -070029
Charles Chane849c192016-01-11 18:28:54 -080030 /**
31 * Constructs the key of per subnet VLAN ID store.
32 *
33 * @param deviceId device ID of the VLAN cross-connection
34 * @param subnet subnet information
35 */
Pier Ventre10bd8d12016-11-26 21:05:22 -080036 public SubnetAssignedVidStoreKey(DeviceId deviceId, IpPrefix subnet) {
Saurav Das0e99e2b2015-10-28 12:39:42 -070037 this.deviceId = deviceId;
38 this.subnet = subnet;
39 }
40
41 /**
Pier Ventref4b5fce2016-11-28 16:48:06 -080042 * Default constructor for Kryo.
43 */
44 protected SubnetAssignedVidStoreKey() {
45 this.deviceId = null;
46 this.subnet = null;
47 }
48
49 /**
Saurav Das0e99e2b2015-10-28 12:39:42 -070050 * Returns the device identification used to create this key.
51 *
52 * @return the device identifier
53 */
54 public DeviceId deviceId() {
55 return deviceId;
56 }
57
58 /**
59 * Returns the subnet information used to create this key.
60 *
61 * @return the subnet
62 */
Pier Ventre10bd8d12016-11-26 21:05:22 -080063 public IpPrefix subnet() {
Saurav Das0e99e2b2015-10-28 12:39:42 -070064 return subnet;
65 }
66
67 @Override
68 public boolean equals(Object o) {
69 if (this == o) {
70 return true;
71 }
72 if (!(o instanceof SubnetAssignedVidStoreKey)) {
73 return false;
74 }
75 SubnetAssignedVidStoreKey that =
76 (SubnetAssignedVidStoreKey) o;
77 return (Objects.equals(this.deviceId, that.deviceId) &&
78 Objects.equals(this.subnet, that.subnet));
79 }
80
81 @Override
82 public int hashCode() {
83 int result = 17;
84 result = 31 * result + Objects.hashCode(deviceId)
85 + Objects.hashCode(subnet);
86 return result;
87 }
88
89 @Override
90 public String toString() {
91 return "Device: " + deviceId + " Subnet: " + subnet;
92 }
93
94}