Record Class ScriptHealth
java.lang.Object
java.lang.Record
com.botwithus.bot.api.runtime.ScriptHealth
Immutable snapshot of a script's failure history. Held atomically by the
runtime; mutated only by replacing the whole record via
withCrash(LastCrash).
lastCrash is empty when the script has never thrown; otherwise
it holds the most recent failure. totalCrashes counts every
failure observed since the runner was constructed (not just the current
lifetime, since the same ScriptRunner can be restarted).
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionScriptHealth(Optional<LastCrash> lastCrash, long totalCrashes) Creates an instance of aScriptHealthrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thelastCrashrecord component.final StringtoString()Returns a string representation of this record class.longReturns the value of thetotalCrashesrecord component.Returns a newScriptHealthwith the given crash recorded andtotalCrashesincremented by one.
-
Field Details
-
HEALTHY
Sentinel for a never-crashed script.
-
-
Constructor Details
-
ScriptHealth
-
-
Method Details
-
withCrash
Returns a newScriptHealthwith the given crash recorded andtotalCrashesincremented by one. The receiver is unmodified. -
toString
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
lastCrash
-
totalCrashes
public long totalCrashes()Returns the value of thetotalCrashesrecord component.- Returns:
- the value of the
totalCrashesrecord component
-