Class ClickHouseDeferredValue<T>

  • All Implemented Interfaces:
    Supplier<T>

    public final class ClickHouseDeferredValue<T>
    extends Object
    implements Supplier<T>
    This class represents a deferred value. It holds a reference to a Supplier or Future to retrieve value only when get() or getOptional() was called.
    • Method Detail

      • of

        public static <T> ClickHouseDeferredValue<T> of​(CompletableFuture<T> future)
        Wraps a future object.
        Type Parameters:
        T - type of the value
        Parameters:
        future - future object, could be null
        Returns:
        deferred value of a future object
      • of

        public static <T> ClickHouseDeferredValue<T> of​(CompletableFuture<T> future,
                                                        int timeout)
        Wraps a future object.
        Type Parameters:
        T - type of the value
        Parameters:
        future - future object, could be null
        timeout - timeout in milliseconds, zero or negative number means no timeout
        Returns:
        deferred vaue of a future object
      • of

        public static <T> ClickHouseDeferredValue<T> of​(Supplier<T> supplier)
        Wraps return value from a supplier function.
        Type Parameters:
        T - type of the value
        Parameters:
        supplier - supplier function, could be null
        Returns:
        deferred value of return value from supplier function
      • of

        public static <T> ClickHouseDeferredValue<T> of​(T value,
                                                        Class<T> clazz)
        Wraps given value as a deferred value.
        Type Parameters:
        T - type of the value
        Parameters:
        value - value to wrap
        clazz - class of the value
        Returns:
        deferred value
      • get

        public T get()
        Specified by:
        get in interface Supplier<T>
      • getOptional

        public Optional<T> getOptional()
        Gets optional value, which may or may not be null.
        Returns:
        optional value