Record Class SystemMetrics

java.lang.Object
java.lang.Record
com.guinetik.hexafun.examples.sysmon.SystemMetrics
Record Components:
cpu - CPU usage percentage (0-100)
memory - Memory usage percentage (0-100)
disk - Disk usage percentage (0-100)

public record SystemMetrics(double cpu, double memory, double disk) extends Record
Domain record representing system metrics.

This is the core domain object that flows through the hexagonal architecture. Different adapters transform this same data into various output formats.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Threshold for warning indicators.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SystemMetrics(double cpu, double memory, double disk)
    Creates an instance of a SystemMetrics record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    cpu()
    Returns the value of the cpu record component.
    boolean
    Check if CPU usage is above warning threshold.
    double
    Returns the value of the disk record component.
    boolean
    Check if disk usage is above warning threshold.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Check if any metric is above warning threshold.
    double
    Returns the value of the memory record component.
    boolean
    Check if memory usage is above warning threshold.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • WARNING_THRESHOLD

      public static final double WARNING_THRESHOLD
      Threshold for warning indicators.
      See Also:
  • Constructor Details

    • SystemMetrics

      public SystemMetrics(double cpu, double memory, double disk)
      Creates an instance of a SystemMetrics record class.
      Parameters:
      cpu - the value for the cpu record component
      memory - the value for the memory record component
      disk - the value for the disk record component
  • Method Details

    • cpuWarning

      public boolean cpuWarning()
      Check if CPU usage is above warning threshold.
    • memoryWarning

      public boolean memoryWarning()
      Check if memory usage is above warning threshold.
    • diskWarning

      public boolean diskWarning()
      Check if disk usage is above warning threshold.
    • hasWarnings

      public boolean hasWarnings()
      Check if any metric is above warning threshold.
    • 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. All components in this record class are compared with '=='.
      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.
    • cpu

      public double cpu()
      Returns the value of the cpu record component.
      Returns:
      the value of the cpu record component
    • memory

      public double memory()
      Returns the value of the memory record component.
      Returns:
      the value of the memory record component
    • disk

      public double disk()
      Returns the value of the disk record component.
      Returns:
      the value of the disk record component