Package oracle.dbtools.plugin.api.conf
Class TimeDuration
- java.lang.Object
-
- oracle.dbtools.plugin.api.conf.TimeDuration
-
- All Implemented Interfaces:
java.lang.Comparable<TimeDuration>,java.time.temporal.TemporalAmount
public class TimeDuration extends java.lang.Object implements java.lang.Comparable<TimeDuration>, java.time.temporal.TemporalAmount
Represents a specification of a time duration. The value is represented textually as an integer followed by one of: "d", "h", "m", or "s", representing days, hours, minutes, or seconds respectively. Milliseconds, microseconds and nanoseconds are represented by "ms","us" and "ns" respectively. If no unit is specified then the default unit of seconds is used.- Author:
- cdivilly
-
-
Constructor Summary
Constructors Constructor Description TimeDuration(long duration, java.util.concurrent.TimeUnit unit)InstantiateTimeDurationinstance
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.time.temporal.TemporaladdTo(java.time.temporal.Temporal temporal)intcompareTo(TimeDuration o)longconvertTo(java.util.concurrent.TimeUnit timeUnit)Convert this TimeDuration into the specifiedTimeUnitdurationstatic TimeDurationdisabled()Obtain aTimeDurationinstance representing a disabled duration checklongduration()Return the raw duration amountbooleanenabled()Indicate if the duration check is enabled or disabled.booleanequals(java.lang.Object obj)booleanexceeded(long start, long end)Test if this duration has been exceededbooleanexceeded(java.time.Instant start, java.time.Instant end)Test if this duration has been exceededlongget(java.time.temporal.TemporalUnit unit)java.util.List<java.time.temporal.TemporalUnit>getUnits()inthashCode()static TimeDurationparse(java.lang.String text)Parse a textual representation of aTimeDurationjava.time.temporal.TemporalsubtractFrom(java.time.temporal.Temporal temporal)longtoMillis()Convert this duration to millisecondsjava.lang.StringtoString()java.util.concurrent.TimeUnitunit()Return theTimeUnitof this duration
-
-
-
Constructor Detail
-
TimeDuration
public TimeDuration(long duration, java.util.concurrent.TimeUnit unit)InstantiateTimeDurationinstance- Parameters:
duration- The amount of the durationunit- TheTimeUnit
-
-
Method Detail
-
compareTo
public int compareTo(TimeDuration o)
- Specified by:
compareToin interfacejava.lang.Comparable<TimeDuration>
-
convertTo
public long convertTo(java.util.concurrent.TimeUnit timeUnit)
Convert this TimeDuration into the specifiedTimeUnitduration- Parameters:
timeUnit- TheTimeUnitto convert this duration to- Returns:
- long value representing the duration in the specified
TimeUnit
-
enabled
public boolean enabled()
Indicate if the duration check is enabled or disabled. If a TimeDuration is initialized with a negative duration value then the duration check is disabled- Returns:
- true if this duration is enabled, false otherwise
- Since:
- 19.3.0
-
duration
public long duration()
Return the raw duration amount- Returns:
- long value indicating the size of the duration
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
exceeded
public boolean exceeded(long start, long end)Test if this duration has been exceeded- Parameters:
start- The starting timestamp (in epoch milliseconds)end- The ending timestamp (in epoch milliseconds)- Returns:
- true if the elapsed time is greater than this duration
-
exceeded
public boolean exceeded(java.time.Instant start, java.time.Instant end)Test if this duration has been exceeded- Parameters:
start- The startingInstantend- The endingInstant- Returns:
- true if the elapsed time is greater than this duration
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toMillis
public long toMillis()
Convert this duration to milliseconds- Returns:
- long value representing the duration in milliseconds
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
unit
public java.util.concurrent.TimeUnit unit()
Return theTimeUnitof this duration- Returns:
TimeUnitvalue
-
disabled
public static TimeDuration disabled()
Obtain aTimeDurationinstance representing a disabled duration check- Returns:
TimeDurationinstance with a duration value of -1 and a TimeUnit of SECONDS
-
parse
public static TimeDuration parse(java.lang.String text)
Parse a textual representation of aTimeDurationThe value is represented textually as an integer followed by one of: followed by one of "d", "h", "m", or "s", representing days, hours, minutes, or seconds respectively. Milliseconds, microseconds and nanoseconds are represented by "ms","us" and "ns" respectively.
If no unit is specified then the default unit of seconds is used.
- Parameters:
text- The textual representation to parse- Returns:
- The equivalent
TimeDurationvalue
-
get
public long get(java.time.temporal.TemporalUnit unit)
- Specified by:
getin interfacejava.time.temporal.TemporalAmount
-
getUnits
public java.util.List<java.time.temporal.TemporalUnit> getUnits()
- Specified by:
getUnitsin interfacejava.time.temporal.TemporalAmount
-
addTo
public java.time.temporal.Temporal addTo(java.time.temporal.Temporal temporal)
- Specified by:
addToin interfacejava.time.temporal.TemporalAmount
-
subtractFrom
public java.time.temporal.Temporal subtractFrom(java.time.temporal.Temporal temporal)
- Specified by:
subtractFromin interfacejava.time.temporal.TemporalAmount
-
-