blob: e90d9e84ecf77c8c050ee2d970b1f6834c952a74 [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 memory stats of device.
24 */
25
26public class DeviceMemoryStats {
27 private long free = 0; // in Bytes
28 private long used = 0;
29 private long total = 0;
30
31 /**
32 * Instantiates DeviceMemoryStats object.
33 */
34 public DeviceMemoryStats() {
35 }
36
37 /**
38 * Creates DeviceMemoryStats object with given data.
39 *
40 * @param free free memory
41 * @param used used memory
42 * @param total total memory
43 */
44 public DeviceMemoryStats(long free, long used, long total) {
45 this.free = free;
46 this.used = used;
47 this.total = total;
48 }
49
50 @Override
51 public String toString() {
52 return MoreObjects.toStringHelper(getClass())
53 .add("free", free)
54 .add("used", used)
55 .add("total", total)
56 .toString();
57 }
58
59 /**
60 * Get total memory of device.
61 *
62 * @return totalMmeory, total memory
63 */
64 public long getTotal() {
65 return total;
66 }
67
68 /**
69 * Get used memory of device.
70 *
71 * @return usedMemory, used memory
72 */
73 public long getUsed() {
74 return used;
75 }
76
77 /**
78 * Get free memory of device.
79 *
80 * @return freeMemory, free memory
81 */
82 public long getFree() {
83 return free;
84 }
85
86 /**
87 * Set free memory of device.
88 *
89 * @param free free memory stats of device
90 */
91 public void setFree(long free) {
92 this.free = free;
93 }
94
95 /**
96 * Set used memory of device.
97 *
98 * @param used used memory stats of device
99 */
100 public void setUsed(long used) {
101 this.used = used;
102 }
103
104 /**
105 * Set total memory of device.
106 *
107 * @param total total memory stats of device
108 */
109 public void setTotal(long total) {
110 this.total = total;
111 }
112
113 @Override
114 public boolean equals(Object o) {
115 if (this == o) {
116 return true;
117 }
118 if (o == null || getClass() != o.getClass()) {
119 return false;
120 }
121 DeviceMemoryStats that = (DeviceMemoryStats) o;
122 return free == that.free &&
123 used == that.used &&
124 total == that.total;
125 }
126
127 @Override
128 public int hashCode() {
129 return Objects.hash(free, used, total);
130 }
131}
132