Record Class SysmonState
java.lang.Object
java.lang.Record
com.guinetik.hexafun.examples.sysmon.SysmonState
- Record Components:
app- The HexaApp instance for invoking use cases and adaptersformat- Current output format selectionwidth- Terminal width for responsive layoutstatus- Status message to displaystatusColor- ANSI color for status messagerunning- Whether the TUI should continue running
public record SysmonState(HexaApp app, SysmonFormat format, int width, String status, String statusColor, boolean running)
extends Record
Immutable state for the System Monitor TUI.
This record holds all state needed to render the UI and process user input. State transitions produce new instances rather than mutating, enabling a functional TUI pattern.
State Transitions
withFormat(SysmonFormat)- Switch output formatwithStatus(String, String)- Show status messagerefresh()- Recalculate metricsstop()- Signal exit
-
Constructor Summary
ConstructorsConstructorDescriptionSysmonState(HexaApp app, SysmonFormat format, int width, String status, String statusColor, boolean running) Creates an instance of aSysmonStaterecord class. -
Method Summary
Modifier and TypeMethodDescriptionapp()Returns the value of theapprecord component.final booleanIndicates whether some other object is "equal to" this one.format()Returns the value of theformatrecord component.final inthashCode()Returns a hash code value for this object.static SysmonStateCreate initial state with default values.metrics()Get current system metrics by invoking the GET_ALL use case.refresh()Refresh state, re-detecting terminal width.booleanrunning()Returns the value of therunningrecord component.status()Returns the value of thestatusrecord component.Returns the value of thestatusColorrecord component.stop()Signal that the TUI should stop.final StringtoString()Returns a string representation of this record class.intwidth()Returns the value of thewidthrecord component.Transition to a new output format.withStatus(String msg, String color) Set a status message.
-
Constructor Details
-
SysmonState
public SysmonState(HexaApp app, SysmonFormat format, int width, String status, String statusColor, boolean running) Creates an instance of aSysmonStaterecord class.- Parameters:
app- the value for theapprecord componentformat- the value for theformatrecord componentwidth- the value for thewidthrecord componentstatus- the value for thestatusrecord componentstatusColor- the value for thestatusColorrecord componentrunning- the value for therunningrecord component
-
-
Method Details
-
initial
Create initial state with default values.- Parameters:
app- The configured HexaApp instance- Returns:
- Initial state ready for rendering
-
withFormat
Transition to a new output format.- Parameters:
f- The new format to use- Returns:
- New state with format changed and status message
-
withStatus
Set a status message.- Parameters:
msg- The message to displaycolor- ANSI color for the message- Returns:
- New state with status updated
-
stop
Signal that the TUI should stop.- Returns:
- New state with running=false
-
refresh
Refresh state, re-detecting terminal width.- Returns:
- New state with cleared status and updated width
-
metrics
Get current system metrics by invoking the GET_ALL use case.- Returns:
- Current SystemMetrics from the provider
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
app
Returns the value of theapprecord component.- Returns:
- the value of the
apprecord component
-
format
Returns the value of theformatrecord component.- Returns:
- the value of the
formatrecord component
-
width
public int width()Returns the value of thewidthrecord component.- Returns:
- the value of the
widthrecord component
-
status
Returns the value of thestatusrecord component.- Returns:
- the value of the
statusrecord component
-
statusColor
Returns the value of thestatusColorrecord component.- Returns:
- the value of the
statusColorrecord component
-
running
public boolean running()Returns the value of therunningrecord component.- Returns:
- the value of the
runningrecord component
-