blob: 086d4d6013ebbdffd9ccdfcf1dbe67129747112d [file] [log] [blame]
alshabib70aaa1b2015-09-25 14:30:59 -07001/*
2 * Copyright 2015 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 com.google.common.base.Objects;
19import org.onosproject.net.DeviceId;
20
21/**
22 * A meter key represents a meter uniquely.
23 */
24public final class MeterKey {
25
26 private final DeviceId deviceId;
27 private final MeterId id;
28
29 private MeterKey(DeviceId deviceId, MeterId id) {
30 this.deviceId = deviceId;
31 this.id = id;
32 }
33
34 public DeviceId deviceId() {
35 return deviceId;
36 }
37
38 public MeterId meterId() {
39 return id;
40 }
41
42 @Override
43 public boolean equals(Object o) {
44 if (this == o) {
45 return true;
46 }
47 if (o == null || getClass() != o.getClass()) {
48 return false;
49 }
50 MeterKey meterKey = (MeterKey) o;
51 return Objects.equal(deviceId, meterKey.deviceId) &&
52 Objects.equal(id, meterKey.id);
53 }
54
55 @Override
56 public int hashCode() {
57 return Objects.hashCode(deviceId, id);
58 }
59
60 public static MeterKey key(DeviceId deviceId, MeterId id) {
61 return new MeterKey(deviceId, id);
62 }
63}