blob: ccc1fc13ddc8a3cdf44869d97aa578f8f8c2064b [file] [log] [blame]
nitinanandf14dccd2018-05-31 15:11:04 +05301/*
2 * Copyright 2016-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.onosproject.net.behaviour;
17
18import com.google.common.base.MoreObjects;
19
20import java.util.Objects;
21
22/**
23 * A representation of cpu stats of device.
24 */
25public class DeviceCpuStats {
26 private float used;
27
28 /**
29 * Instantiates DeviceCpuStats object with default value.
30 */
31 public DeviceCpuStats() {
32 used = 0.0f;
33 }
34
35 /**
36 * Creates DeviceCpuStats object with given value.
37 *
38 * @param used cpu usage of device
39 */
40 public DeviceCpuStats(float used) {
41 this.used = used;
42 }
43
44 /**
45 * Get cpu usage of device.
46 *
47 * @return usedCpu, cpu usage stats of device
48 */
49 public float getUsed() {
50 return used;
51 }
52
53 /**
54 * Set cpu usage of device.
55 *
56 * @param used cpu usage of device
57 */
58 public void setUsed(float used) {
59 this.used = used;
60 }
61
62 @Override
63 public String toString() {
64 return MoreObjects.toStringHelper(getClass())
65 .add("used", used)
66 .toString();
67 }
68
69 @Override
70 public boolean equals(Object o) {
71 if (this == o) {
72 return true;
73 }
74 if (o == null || getClass() != o.getClass()) {
75 return false;
76 }
77 DeviceCpuStats that = (DeviceCpuStats) o;
78 return Float.compare(that.used, used) == 0;
79 }
80
81 @Override
82 public int hashCode() {
83 return Objects.hash(used);
84 }
85}