Package oracle.dbtools.plugin.api.conf
Class TimeDuration
java.lang.Object
oracle.dbtools.plugin.api.conf.TimeDuration
- All Implemented Interfaces:
Comparable<TimeDuration>,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
ConstructorsConstructorDescriptionTimeDuration(long duration, TimeUnit unit) InstantiateTimeDurationinstance -
Method Summary
Modifier and TypeMethodDescriptionintlongConvert 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.booleanbooleanexceeded(long start, long end) Test if this duration has been exceededbooleanTest if this duration has been exceededlongget(TemporalUnit unit) getUnits()inthashCode()static TimeDurationParse a textual representation of aTimeDurationsubtractFrom(Temporal temporal) longtoMillis()Convert this duration to millisecondstoString()unit()Return theTimeUnitof this duration
-
Constructor Details
-
TimeDuration
InstantiateTimeDurationinstance- Parameters:
duration- The amount of the durationunit- TheTimeUnit
-
-
Method Details
-
compareTo
- Specified by:
compareToin interfaceComparable<TimeDuration>
-
convertTo
Convert this TimeDuration into the specifiedTimeUnitduration -
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
-
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
Test if this duration has been exceeded -
hashCode
public int hashCode() -
toMillis
public long toMillis()Convert this duration to milliseconds- Returns:
- long value representing the duration in milliseconds
-
toString
-
unit
Return theTimeUnitof this duration- Returns:
TimeUnitvalue
-
disabled
Obtain aTimeDurationinstance representing a disabled duration check- Returns:
TimeDurationinstance with a duration value of -1 and a TimeUnit of SECONDS
-
parse
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
- Specified by:
getin interfaceTemporalAmount
-
getUnits
- Specified by:
getUnitsin interfaceTemporalAmount
-
addTo
- Specified by:
addToin interfaceTemporalAmount
-
subtractFrom
- Specified by:
subtractFromin interfaceTemporalAmount
-