org.apache.hc.core5.util

## Class Timeout

- java.lang.Object
- - org.apache.hc.core5.util.TimeValue
  - - org.apache.hc.core5.util.Timeout

- All Implemented Interfaces:
    Comparable<TimeValue>

      @Contract(threading=IMMUTABLE)
      public class Timeout
      extends TimeValue

  Represents a timeout value as a non-negative `long` time and `TimeUnit`.
  Since:
    5.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Timeout` | `DISABLED` A disabled timeout represented as 0 `MILLISECONDS`.
    `static Timeout` | `ONE_MILLISECOND` A one milliseconds `Timeout`.
    `static Timeout` | `ZERO_MILLISECONDS` A zero milliseconds `Timeout`.

    - ### Fields inherited from class org.apache.hc.core5.util.TimeValue

      `MAX_VALUE, NEG_ONE_MILLISECOND, NEG_ONE_SECOND`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Timeout` | `defaultsToDisabled(Timeout timeout)` Returns the given `timeout` if it is not `null`, if `null` then returns `DISABLED`.
    `boolean` | `isDisabled()` Whether this timeout is disabled.
    `boolean` | `isEnabled()` Whether this timeout is enabled.
    `static Timeout` | `of(long duration, TimeUnit timeUnit)` Creates a Timeout.
    `static Timeout` | `ofDays(long days)` Creates a Timeout.
    `static Timeout` | `ofHours(long hours)` Creates a Timeout.
    `static Timeout` | `ofMicroseconds(long microseconds)` Creates a Timeout.
    `static Timeout` | `ofMilliseconds(long milliseconds)` Creates a Timeout.
    `static Timeout` | `ofMinutes(long minutes)` Creates a Timeout.
    `static Timeout` | `ofNanoseconds(long nanoseconds)` Creates a Timeout.
    `static Timeout` | `ofSeconds(long seconds)` Creates a Timeout.
    `static Timeout` | `parse(String value)` Parses a Timeout in the format `<Integer><SPACE><TimeUnit>`, for example `"1,200 MILLISECONDS"`

    - ### Methods inherited from class org.apache.hc.core5.util.TimeValue

      `asBoundInt, compareTo, convert, defaultsTo, defaultsToNegativeOneMillisecond, defaultsToNegativeOneSecond, defaultsToZeroMilliseconds, divide, divide, equals, getDuration, getTimeUnit, hashCode, isNonNegative, isPositive, min, sleep, timedJoin, timedWait, toDays, toHours, toMicroseconds, toMilliseconds, toMillisecondsIntBound, toMinutes, toNanoseconds, toSeconds, toSecondsIntBound, toString, toTimeout`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### ZERO_MILLISECONDS

          public static final Timeout ZERO_MILLISECONDS

      A zero milliseconds `Timeout`.

    - #### ONE_MILLISECOND

          public static final Timeout ONE_MILLISECOND

      A one milliseconds `Timeout`.

    - #### DISABLED

          public static final Timeout DISABLED

      A disabled timeout represented as 0 `MILLISECONDS`.

  - ### Method Detail

    - #### defaultsToDisabled

          public static Timeout defaultsToDisabled(Timeout timeout)

      Returns the given `timeout` if it is not `null`, if `null` then returns `DISABLED`.
      Parameters:
        `timeout` - may be `null`
      Returns:
        `timeValue` or `DISABLED`

    - #### of

          public static Timeout of(long duration,
                   TimeUnit timeUnit)

      Creates a Timeout.
      Parameters:
        `duration` - the time duration in the given `timeUnit`.
        `timeUnit` - the time unit for the given duration.
      Returns:
        a Timeout

    - #### ofDays

          public static Timeout ofDays(long days)

      Creates a Timeout.
      Parameters:
        `days` - the duration in days and the given `timeUnit`.
      Returns:
        a Timeout

    - #### ofHours

          public static Timeout ofHours(long hours)

      Creates a Timeout.
      Parameters:
        `hours` - the duration in hours and the given `timeUnit`.
      Returns:
        a Timeout

    - #### ofMicroseconds

          public static Timeout ofMicroseconds(long microseconds)

      Creates a Timeout.
      Parameters:
        `microseconds` - the duration in seconds and the given `timeUnit`.
      Returns:
        a Timeout

    - #### ofMilliseconds

          public static Timeout ofMilliseconds(long milliseconds)

      Creates a Timeout.
      Parameters:
        `milliseconds` - the duration in milliseconds and the given `timeUnit`.
      Returns:
        a Timeout

    - #### ofMinutes

          public static Timeout ofMinutes(long minutes)

      Creates a Timeout.
      Parameters:
        `minutes` - the duration in minutes and the given `timeUnit`.
      Returns:
        a Timeout

    - #### ofNanoseconds

          public static Timeout ofNanoseconds(long nanoseconds)

      Creates a Timeout.
      Parameters:
        `nanoseconds` - the duration in seconds and the given `timeUnit`.
      Returns:
        a Timeout

    - #### ofSeconds

          public static Timeout ofSeconds(long seconds)

      Creates a Timeout.
      Parameters:
        `seconds` - the duration in seconds and the given `timeUnit`.
      Returns:
        a Timeout

    - #### parse

          public static Timeout parse(String value)
                               throws ParseException

      Parses a Timeout in the format `<Integer><SPACE><TimeUnit>`, for example `"1,200 MILLISECONDS"`
      Parameters:
        `value` - the TimeValue to parse
      Returns:
        a new TimeValue
      Throws:
        `ParseException` - if the number cannot be parsed

    - #### isDisabled

          public boolean isDisabled()

      Whether this timeout is disabled.
      Returns:
        Whether this timeout is disabled.

    - #### isEnabled

          public boolean isEnabled()

      Whether this timeout is enabled.
      Returns:
        Whether this timeout is disabled.

Copyright © 2005–2020 The Apache Software Foundation. All rights reserved.