Record Class Duration
java.lang.Object
java.lang.Record
org.jenkinsci.plugins.additionalmetrics.Duration
Represents a time duration in milliseconds.
Provides methods to access the duration as a long value or as a human-readable string.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.longReturns the duration in milliseconds.Returns the duration as a human-readable time span string.final inthashCode()Returns a hash code value for this object.longReturns the value of themillisecondsrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Duration
public Duration(long milliseconds) Creates an instance of aDurationrecord class.- Parameters:
milliseconds- the value for themillisecondsrecord component
-
-
Method Details
-
getAsLong
public long getAsLong()Returns the duration in milliseconds.- Returns:
- the duration value in milliseconds
-
getAsString
Returns the duration as a human-readable time span string. Uses Jenkins' utility method to format the duration (e.g., "2 hr 30 min").- Returns:
- the duration formatted as a human-readable 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. -
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. All components in this record class are compared with '=='. -
milliseconds
public long milliseconds()Returns the value of themillisecondsrecord component.- Returns:
- the value of the
millisecondsrecord component
-