Record Class BoundedDuration
java.lang.Object
java.lang.Record
com.winterhavenmc.library.messagebuilder.pipeline.formatters.duration.BoundedDuration
- Record Components:
duration
- the time-based duration to formatprecision
- the lowestChronoUnit
to include in the formatted result
A simple data container that encapsulates a
Duration
and its corresponding lower bound of precision, represented by a ChronoUnit
.
This record is typically used in conjunction with duration formatters to specify not only the length of time to be formatted, but also the level of detail or granularity to include in the formatted output (e.g., rounding to the nearest minute, second, etc.).
For example, a BoundedDuration
of Duration.ofSeconds(4110)
with
ChronoUnit.MINUTES
as the precision might format to "1 hour, 8 minutes"
rather than
"1 hour, 8 minutes and 30 seconds"
, depending on the formatter implementation.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBoundedDuration
(Duration duration, ChronoUnit precision) Creates an instance of aBoundedDuration
record class. -
Method Summary
Modifier and TypeMethodDescriptionduration()
Returns the value of theduration
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.Returns the value of theprecision
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
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 withObjects::equals(Object,Object)
. -
duration
Returns the value of theduration
record component.- Returns:
- the value of the
duration
record component
-
precision
Returns the value of theprecision
record component.- Returns:
- the value of the
precision
record component
-