View Javadoc
1   package com.guinetik.hexafun.examples.sysmon;
2   
3   /**
4    * Domain record representing system metrics.
5    *
6    * <p>This is the core domain object that flows through the hexagonal architecture.
7    * Different adapters transform this same data into various output formats.</p>
8    *
9    * @param cpu CPU usage percentage (0-100)
10   * @param memory Memory usage percentage (0-100)
11   * @param disk Disk usage percentage (0-100)
12   */
13  public record SystemMetrics(double cpu, double memory, double disk) {
14  
15      /**
16       * Threshold for warning indicators.
17       */
18      public static final double WARNING_THRESHOLD = 80.0;
19  
20      /**
21       * Check if CPU usage is above warning threshold.
22       */
23      public boolean cpuWarning() {
24          return cpu >= WARNING_THRESHOLD;
25      }
26  
27      /**
28       * Check if memory usage is above warning threshold.
29       */
30      public boolean memoryWarning() {
31          return memory >= WARNING_THRESHOLD;
32      }
33  
34      /**
35       * Check if disk usage is above warning threshold.
36       */
37      public boolean diskWarning() {
38          return disk >= WARNING_THRESHOLD;
39      }
40  
41      /**
42       * Check if any metric is above warning threshold.
43       */
44      public boolean hasWarnings() {
45          return cpuWarning() || memoryWarning() || diskWarning();
46      }
47  }