blob: be49f96fc0d80a2b5eff65f42da3609babcef7b3 [file] [log] [blame]
Jordi Ortizaa8de492016-12-01 00:21:36 +01001/*
2 * Copyright 2016-present 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 */
16package org.onosproject.net.meter;
17
18import org.onosproject.net.DeviceId;
19
20import java.util.Objects;
21
22/**
23 * A meter features key represents a meter features uniquely.
24 * Right now only deviceId is used but this class might be useful in
25 * virtualization in which a unique deviceId could have multiple features (guess).
26 */
27public final class MeterFeaturesKey {
28 private final DeviceId deviceId;
29
30 private MeterFeaturesKey(DeviceId deviceId) {
31 this.deviceId = deviceId;
32 }
33
34 public static MeterFeaturesKey key(DeviceId did) {
35 return new MeterFeaturesKey(did);
36 }
37
38 @Override
39 public boolean equals(Object obj) {
40 if (this == obj) {
41 return true;
42 }
43 if (obj == null || getClass() != obj.getClass()) {
44 return false;
45 }
46 MeterFeaturesKey mfk = (MeterFeaturesKey) obj;
47 return Objects.equals(deviceId, mfk.deviceId());
48 }
49
50 @Override
51 public int hashCode() {
52 return Objects.hashCode(deviceId);
53 }
54
55 @Override
56 public String toString() {
57 return "mfk@" + deviceId.toString();
58 }
59
60 public DeviceId deviceId() {
61 return deviceId;
62 }
63}