blob: 0bdacdc6c32cbdfc62842f405ec2b22d30ebb737 [file] [log] [blame]
Marcos Aurelio Carrerodadb3572019-11-25 13:34:25 -03001/*
2 * Copyright 2017-present Open Networking Foundation
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 */
16package org.opencord.dhcpl2relay.impl;
17
18import java.util.Objects;
19
20/**
21 * Represents DHCP relay counters identifier.
22 */
23public final class DhcpL2RelayCountersIdentifier {
24 final String counterClassKey;
25 final Enum<DhcpL2RelayCounters> counterTypeKey;
26 static final String GLOBAL_COUNTER = "global";
27
28 /**
29 * Creates a default global counter identifier for a given counterType.
30 *
31 * @param counterTypeKey Identifies the supported type of DHCP relay counters
32 */
33 public DhcpL2RelayCountersIdentifier(DhcpL2RelayCounters counterTypeKey) {
34 this.counterClassKey = GLOBAL_COUNTER;
35 this.counterTypeKey = counterTypeKey;
36 }
37
38 /**
39 * Creates a counter identifier. A counter is defined by the key pair <counterClass, counterType>,
40 * where counterClass can be maybe global or the subscriber ID and counterType is the supported DHCP message type.
41 *
42 * @param counterClassKey Identifies which class the counter is assigned (global or per subscriber)
43 * @param counterTypeKey Identifies the supported type of DHCP relay counters
44 */
45 public DhcpL2RelayCountersIdentifier(String counterClassKey, DhcpL2RelayCounters counterTypeKey) {
46 this.counterClassKey = counterClassKey;
47 this.counterTypeKey = counterTypeKey;
48 }
49
50 @Override
51 public boolean equals(Object obj) {
52 if (this == obj) {
53 return true;
54 }
55 if (obj instanceof DhcpL2RelayCountersIdentifier) {
56 final DhcpL2RelayCountersIdentifier other = (DhcpL2RelayCountersIdentifier) obj;
57 return Objects.equals(this.counterClassKey, other.counterClassKey)
58 && Objects.equals(this.counterTypeKey, other.counterTypeKey);
59 }
60
61 return false;
62 }
63
64 @Override
65 public int hashCode() {
66 return Objects.hash(counterClassKey, counterTypeKey);
67 }
68}