aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SubnetAssignedVidStoreKey.java
blob: 84b44c97f23bab22a784a8bd23f4531dfc68e721 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package org.onosproject.segmentrouting;

import java.util.Objects;

import org.onlab.packet.Ip4Prefix;
import org.onosproject.net.DeviceId;

/**
 * Class definition for key used to map per device subnets to assigned Vlan ids.
 *
 */
public class SubnetAssignedVidStoreKey {
    private final DeviceId deviceId;
    private final Ip4Prefix subnet;

    public SubnetAssignedVidStoreKey(DeviceId deviceId, Ip4Prefix subnet) {
        this.deviceId = deviceId;
        this.subnet = subnet;
    }

    /**
     * Returns the device identification used to create this key.
     *
     * @return the device identifier
     */
    public DeviceId deviceId() {
        return deviceId;
    }

    /**
     * Returns the subnet information used to create this key.
     *
     * @return the subnet
     */
    public Ip4Prefix subnet() {
        return subnet;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof SubnetAssignedVidStoreKey)) {
            return false;
        }
        SubnetAssignedVidStoreKey that =
                (SubnetAssignedVidStoreKey) o;
        return (Objects.equals(this.deviceId, that.deviceId) &&
                Objects.equals(this.subnet, that.subnet));
    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + Objects.hashCode(deviceId)
                + Objects.hashCode(subnet);
        return result;
    }

    @Override
    public String toString() {
        return "Device: " + deviceId + " Subnet: " + subnet;
    }

}