View Javadoc
1   /*
2    * Copyright 2019-2022 The OSHI Project Contributors
3    * SPDX-License-Identifier: MIT
4    */
5   package oshi.hardware.common;
6   
7   import oshi.annotation.concurrent.ThreadSafe;
8   import oshi.hardware.VirtualMemory;
9   import oshi.util.FormatUtil;
10  
11  /**
12   * Virtual Memory info.
13   */
14  @ThreadSafe
15  public abstract class AbstractVirtualMemory implements VirtualMemory {
16  
17      @Override
18      public String toString() {
19          StringBuilder sb = new StringBuilder();
20          sb.append("Swap Used/Avail: ");
21          sb.append(FormatUtil.formatBytes(getSwapUsed()));
22          sb.append("/");
23          sb.append(FormatUtil.formatBytes(getSwapTotal()));
24          sb.append(", Virtual Memory In Use/Max=");
25          sb.append(FormatUtil.formatBytes(getVirtualInUse()));
26          sb.append("/");
27          sb.append(FormatUtil.formatBytes(getVirtualMax()));
28          return sb.toString();
29      }
30  }