Record Class OsInfo

java.lang.Object
java.lang.Record
cloud.opencode.base.core.system.OsInfo
Record Components:
name - operating system name - 操作系统名称
version - operating system version - 操作系统版本
arch - processor architecture - 处理器架构
hostname - machine hostname - 主机名
availableProcessors - number of available processors - 可用处理器数量
physicalMemoryTotal - total physical memory in bytes - 总物理内存(字节)
swapTotal - total swap space in bytes - 总交换空间(字节)

public record OsInfo(String name, String version, String arch, String hostname, int availableProcessors, long physicalMemoryTotal, long swapTotal) extends Record
Immutable snapshot of operating system information. 操作系统信息的不可变快照。

Captures OS name, version, architecture, hostname, and basic hardware metrics at the time of creation.

捕获创建时的操作系统名称、版本、架构、主机名和基本硬件指标。

Usage Examples | 使用示例:

OsInfo os = SystemInfo.os();
System.out.println("OS: " + os.name() + " " + os.version());
System.out.println("Host: " + os.hostname());
Since:
JDK 25, opencode-base-core V1.0.3
Author:
Leon Soo
See Also:
  • Constructor Details

    • OsInfo

      public OsInfo(String name, String version, String arch, String hostname, int availableProcessors, long physicalMemoryTotal, long swapTotal)
      Compact canonical constructor with validation. 带验证的紧凑规范构造器。
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • version

      public String version()
      Returns the value of the version record component.
      Returns:
      the value of the version record component
    • arch

      public String arch()
      Returns the value of the arch record component.
      Returns:
      the value of the arch record component
    • hostname

      public String hostname()
      Returns the value of the hostname record component.
      Returns:
      the value of the hostname record component
    • availableProcessors

      public int availableProcessors()
      Returns the value of the availableProcessors record component.
      Returns:
      the value of the availableProcessors record component
    • physicalMemoryTotal

      public long physicalMemoryTotal()
      Returns the value of the physicalMemoryTotal record component.
      Returns:
      the value of the physicalMemoryTotal record component
    • swapTotal

      public long swapTotal()
      Returns the value of the swapTotal record component.
      Returns:
      the value of the swapTotal record component