blob: 3603b3aeafcc8093c276c2fc1010d2ec18b95f97 [file] [log] [blame]
Jian Li60804322015-12-02 14:46:31 -08001/*
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.cpman;
17
18import static com.google.common.base.MoreObjects.toStringHelper;
19
20/**
21 * Primitive Metric Value.
22 */
23public class MetricValue {
24
25 private final long rate;
26 private final long load;
27 private final long count;
28
29 /**
30 * Constructor.
31 *
32 * @param rate rate
33 * @param load load
34 * @param count count
35 */
36 MetricValue(long rate, long load, long count) {
37 this.rate = rate;
38 this.load = load;
39 this.count = count;
40 }
41
42 public long getRate() {
43 return rate;
44 }
45
46 public long getLoad() {
47 return load;
48 }
49
50 public long getCount() {
51 return count;
52 }
53
54 @Override
55 public boolean equals(Object obj) {
56 if (this == obj) {
57 return true;
58 }
59 if (obj instanceof MetricValue) {
60 MetricValue other = (MetricValue) obj;
61 if (this.rate == other.rate &&
62 this.load == other.load &&
63 this.count == other.count) {
64 return true;
65 }
66 }
67 return false;
68 }
69
70 @Override
71 public int hashCode() {
72 final int prime = 1004;
73 int result = super.hashCode();
74 result = prime * result + (int) this.rate;
75 result = prime * result + (int) this.load;
76 result = prime * result + (int) this.count;
77 return result;
78 }
79
80 @Override
81 public String toString() {
82 return toStringHelper(getClass())
83 .add("rate", Long.toHexString(rate))
84 .add("load", Long.toHexString(load))
85 .add("count", Long.toHexString(count)).toString();
86 }
87}