net.corda.core

## Class Utils

- net.corda.core.Utils

-     public class Utils

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `abbreviate(java.lang.String $receiver, int maxWidth)`
    `static <T> rx.Observable<T>` | `bufferUntilSubscribed(rx.Observable<T> $receiver)` Returns an Observable that buffers events until subscribed.
    `static <T> void` | `catch(com.google.common.util.concurrent.SettableFuture<T> $receiver, kotlin.jvm.functions.Function0<? extends T> block)` Executes the given block and sets the future to either the result, or any exception that was thrown.
    `static int` | `checkedAdd(int $receiver, int b)` Like the + operator but throws an exception in case of integer overflow.
    `static long` | `checkedAdd(long $receiver, long b)` Like the + operator but throws an exception in case of integer overflow.
    `static java.lang.String` | `codePointsString(int codePoints)`
    `static long` | `copyTo(java.io.InputStream $receiver, java.nio.file.Path target, java.nio.file.CopyOption options)`
    `static java.nio.file.Path` | `createDirectories(java.nio.file.Path $receiver, java.nio.file.attribute.FileAttribute attrs)`
    `static java.nio.file.Path` | `createDirectory(java.nio.file.Path $receiver, java.nio.file.attribute.FileAttribute attrs)`
    `static boolean` | `deleteIfExists(java.nio.file.Path $receiver)`
    `static java.nio.file.Path` | `div(java.nio.file.Path $receiver, java.lang.String other)` Allows you to write code like: Paths.get("someDir") / "subdir" / "filename" but using the Paths API to avoid platform separator problems.
    `static java.time.Duration` | `elapsedTime(kotlin.jvm.functions.Function0<kotlin.Unit> block)`
    `static boolean` | `exists(java.nio.file.Path $receiver, java.nio.file.LinkOption options)`
    `static void` | `extractZipFile(java.nio.file.Path zipFile, java.nio.file.Path toDirectory)` Given a path to a zip file, extracts it to the given directory.
    `static <T> void` | `failure(com.google.common.util.concurrent.ListenableFuture<T> $receiver, java.util.concurrent.Executor executor, kotlin.jvm.functions.Function1<? super java.lang.Throwable,kotlin.Unit> body)`
    `static <T> com.google.common.util.concurrent.ListenableFuture<T>` | `failure(com.google.common.util.concurrent.ListenableFuture<T> $receiver, kotlin.jvm.functions.Function1<? super java.lang.Throwable,kotlin.Unit> body)`
    `static <F,T> com.google.common.util.concurrent.ListenableFuture<T>` | `flatMap(com.google.common.util.concurrent.ListenableFuture<F> $receiver, kotlin.jvm.functions.Function1<? super F,? extends com.google.common.util.concurrent.ListenableFuture<T>> mapper)`
    `static <T> com.google.common.util.concurrent.ListenableFuture<T>` | `future(kotlin.jvm.functions.Function0<? extends T> block)`
    `static java.math.BigDecimal` | `getBd(int $receiver)`
    `static java.math.BigDecimal` | `getBd(double $receiver)`
    `static java.math.BigDecimal` | `getBd(java.lang.String $receiver)`
    `static java.math.BigDecimal` | `getBd(long $receiver)`
    `static java.time.Duration` | `getDays(int $receiver)`
    `static java.time.Duration` | `getHours(int $receiver)`
    `static java.time.Duration` | `getMillis(int $receiver)`
    `static java.time.Duration` | `getMinutes(int $receiver)`
    `static <T> T` | `getOrThrow(java.util.concurrent.Future<T> $receiver, java.time.Duration timeout)` Same as Future.get but with a more descriptive name, and doesn't throw ExecutionException, instead throwing its cause
    `static java.lang.Throwable` | `getRootCause(java.lang.Throwable $receiver)`
    `static java.util.concurrent.Executor` | `getRunOnCallerThread()`
    `static java.time.Duration` | `getSeconds(int $receiver)`
    `static long` | `getSize(java.nio.file.Path $receiver)`
    `static <T> int` | `indexOfOrThrow(java.util.List<? extends T> $receiver, T item)` Returns the index of the given item or throws IllegalArgumentException if not found.
    `static boolean` | `isDirectory(java.nio.file.Path $receiver, java.nio.file.LinkOption options)`
    `static boolean` | `isRegularFile(java.nio.file.Path $receiver, java.nio.file.LinkOption options)`
    `static <R> R` | `list(java.nio.file.Path $receiver, kotlin.jvm.functions.Function1<? super java.util.stream.Stream<java.nio.file.Path>,? extends R> block)`
    `static <T> T` | `logElapsedTime(java.lang.String label, org.slf4j.Logger logger, kotlin.jvm.functions.Function0<? extends T> body)`
    `static <T> T` | `logElapsedTime(org.slf4j.Logger $receiver, java.lang.String label, kotlin.jvm.functions.Function0<? extends T> body)`
    `static <F,T> com.google.common.util.concurrent.ListenableFuture<T>` | `map(com.google.common.util.concurrent.ListenableFuture<F> $receiver, kotlin.jvm.functions.Function1<? super F,? extends T> mapper)`
    `static java.nio.file.Path` | `moveTo(java.nio.file.Path $receiver, java.nio.file.Path target, java.nio.file.CopyOption options)`
    `static <T> T` | `noneOrSingle(java.lang.Iterable<? extends T> $receiver, kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> predicate)` Returns the single element matching the given predicate, or `null` if element was not found, or throws if more than one element was found.
    `static <T> T` | `noneOrSingle(java.lang.Iterable<? extends T> $receiver)` Returns single element, or `null` if element was not found, or throws if more than one element was found.
    `static long` | `random63BitValue()` Returns a random positive long generated using a secure RNG. This function sacrifies a bit of entropy in order to avoid potential bugs where the value is used in a context where negative numbers are not expected.
    `static <T> T` | `randomOrNull(java.util.List<? extends T> $receiver)` Returns a random element in the list, or null if empty
    `static <T> T` | `randomOrNull(java.util.List<? extends T> $receiver, kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> predicate)` Returns a random element in the list matching the given predicate, or null if none found
    `static <R> R` | `read(java.nio.file.Path $receiver, java.nio.file.OpenOption[] options, kotlin.jvm.functions.Function1<? super java.io.InputStream,? extends R> block)`
    `static byte[]` | `readAll(java.nio.file.Path $receiver)`
    `static <R> R` | `readLines(java.nio.file.Path $receiver, java.nio.charset.Charset charset, kotlin.jvm.functions.Function1<? super java.util.stream.Stream<java.lang.String>,? extends R> block)`
    `static <T> void` | `success(com.google.common.util.concurrent.ListenableFuture<T> $receiver, java.util.concurrent.Executor executor, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> body)`
    `static <T> com.google.common.util.concurrent.ListenableFuture<T>` | `success(com.google.common.util.concurrent.ListenableFuture<T> $receiver, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> body)`
    `static java.math.BigDecimal` | `sum(java.lang.Iterable<? extends java.math.BigDecimal> $receiver)` Return the sum of an Iterable of BigDecimals.
    `static <T> rx.Observer<T>` | `tee(rx.Observer<T> $receiver, rx.Observer teeTo)` Copy an Observer to multiple other Observers.
    `static <T> void` | `then(com.google.common.util.concurrent.ListenableFuture<T> $receiver, java.util.concurrent.Executor executor, kotlin.jvm.functions.Function0<kotlin.Unit> body)`
    `static <T> com.google.common.util.concurrent.ListenableFuture<T>` | `then(com.google.common.util.concurrent.ListenableFuture<T> $receiver, kotlin.jvm.functions.Function0<kotlin.Unit> body)`
    `static <T> com.google.common.util.concurrent.ListenableFuture<T>` | `toFuture(rx.Observable<T> $receiver)` Returns a ListenableFuture bound to the first item emitted by this Observable. The future will complete with a NoSuchElementException if no items are emitted or any other error thrown by the Observable. If it's cancelled then it will unsubscribe from the observable.
    `static <A> rx.Observable<A>` | `toObservable(com.google.common.util.concurrent.ListenableFuture<? extends A> $receiver)`
    `static java.time.Duration` | `until(java.time.temporal.Temporal $receiver, java.time.temporal.Temporal endExclusive)`
    `static void` | `write(java.nio.file.Path $receiver, boolean createDirs, java.nio.file.OpenOption[] options, kotlin.jvm.functions.Function1<? super java.io.OutputStream,kotlin.Unit> block)`
    `static java.nio.file.Path` | `writeLines(java.nio.file.Path $receiver, java.lang.Iterable<? extends java.lang.CharSequence> lines, java.nio.charset.Charset charset, java.nio.file.OpenOption options)`

- - ### Method Detail

    - #### getDays

          public static java.time.Duration getDays(int $receiver)

    - #### getHours

          public static java.time.Duration getHours(int $receiver)

    - #### getMinutes

          public static java.time.Duration getMinutes(int $receiver)

    - #### getSeconds

          public static java.time.Duration getSeconds(int $receiver)

    - #### getMillis

          public static java.time.Duration getMillis(int $receiver)

    - #### getBd

          public static java.math.BigDecimal getBd(int $receiver)

    - #### getBd

          public static java.math.BigDecimal getBd(double $receiver)

    - #### getBd

          public static java.math.BigDecimal getBd(java.lang.String $receiver)

    - #### getBd

          public static java.math.BigDecimal getBd(long $receiver)

    - #### abbreviate

          public static java.lang.String abbreviate(java.lang.String $receiver,
                                                    int maxWidth)

    - #### checkedAdd

          public static int checkedAdd(int $receiver,
                                       int b)

      Like the + operator but throws an exception in case of integer overflow.

    - #### checkedAdd

          public static long checkedAdd(long $receiver,
                                        long b)

      Like the + operator but throws an exception in case of integer overflow.

    - #### random63BitValue

          public static long random63BitValue()

      Returns a random positive long generated using a secure RNG. This function sacrifies a bit of entropy in order to avoid potential bugs where the value is used in a context where negative numbers are not expected.

    - #### getOrThrow

          public static <T> T getOrThrow(java.util.concurrent.Future<T> $receiver,
                                         java.time.Duration timeout)

      Same as Future.get but with a more descriptive name, and doesn't throw ExecutionException, instead throwing its cause

      See Also:
        Future.get, ExecutionException

    - #### future

          public static <T> com.google.common.util.concurrent.ListenableFuture<T> future(kotlin.jvm.functions.Function0<? extends T> block)

    - #### then

          public static <T> void then(com.google.common.util.concurrent.ListenableFuture<T> $receiver,
                                      java.util.concurrent.Executor executor,
                                      kotlin.jvm.functions.Function0<kotlin.Unit> body)

    - #### success

          public static <T> void success(com.google.common.util.concurrent.ListenableFuture<T> $receiver,
                                         java.util.concurrent.Executor executor,
                                         kotlin.jvm.functions.Function1<? super T,kotlin.Unit> body)

    - #### failure

          public static <T> void failure(com.google.common.util.concurrent.ListenableFuture<T> $receiver,
                                         java.util.concurrent.Executor executor,
                                         kotlin.jvm.functions.Function1<? super java.lang.Throwable,kotlin.Unit> body)

    - #### then

          public static <T> com.google.common.util.concurrent.ListenableFuture<T> then(com.google.common.util.concurrent.ListenableFuture<T> $receiver,
                                                                                       kotlin.jvm.functions.Function0<kotlin.Unit> body)

    - #### success

          public static <T> com.google.common.util.concurrent.ListenableFuture<T> success(com.google.common.util.concurrent.ListenableFuture<T> $receiver,
                                                                                          kotlin.jvm.functions.Function1<? super T,kotlin.Unit> body)

    - #### failure

          public static <T> com.google.common.util.concurrent.ListenableFuture<T> failure(com.google.common.util.concurrent.ListenableFuture<T> $receiver,
                                                                                          kotlin.jvm.functions.Function1<? super java.lang.Throwable,kotlin.Unit> body)

    - #### map

          public static <F,T> com.google.common.util.concurrent.ListenableFuture<T> map(com.google.common.util.concurrent.ListenableFuture<F> $receiver,
                                                                                        kotlin.jvm.functions.Function1<? super F,? extends T> mapper)

    - #### flatMap

          public static <F,T> com.google.common.util.concurrent.ListenableFuture<T> flatMap(com.google.common.util.concurrent.ListenableFuture<F> $receiver,
                                                                                            kotlin.jvm.functions.Function1<? super F,? extends com.google.common.util.concurrent.ListenableFuture<T>> mapper)

    - #### catch

          public static <T> void catch(com.google.common.util.concurrent.SettableFuture<T> $receiver,
                                       kotlin.jvm.functions.Function0<? extends T> block)

      Executes the given block and sets the future to either the result, or any exception that was thrown.

    - #### toObservable

          public static <A> rx.Observable<A> toObservable(com.google.common.util.concurrent.ListenableFuture<? extends A> $receiver)

    - #### div

          public static java.nio.file.Path div(java.nio.file.Path $receiver,
                                               java.lang.String other)

      Allows you to write code like: Paths.get("someDir") / "subdir" / "filename" but using the Paths API to avoid platform separator problems.

    - #### createDirectory

          public static java.nio.file.Path createDirectory(java.nio.file.Path $receiver,
                                                           java.nio.file.attribute.FileAttribute attrs)

    - #### createDirectories

          public static java.nio.file.Path createDirectories(java.nio.file.Path $receiver,
                                                             java.nio.file.attribute.FileAttribute attrs)

    - #### exists

          public static boolean exists(java.nio.file.Path $receiver,
                                       java.nio.file.LinkOption options)

    - #### moveTo

          public static java.nio.file.Path moveTo(java.nio.file.Path $receiver,
                                                  java.nio.file.Path target,
                                                  java.nio.file.CopyOption options)

    - #### isRegularFile

          public static boolean isRegularFile(java.nio.file.Path $receiver,
                                              java.nio.file.LinkOption options)

    - #### isDirectory

          public static boolean isDirectory(java.nio.file.Path $receiver,
                                            java.nio.file.LinkOption options)

    - #### getSize

          public static long getSize(java.nio.file.Path $receiver)

    - #### list

          public static <R> R list(java.nio.file.Path $receiver,
                                   kotlin.jvm.functions.Function1<? super java.util.stream.Stream<java.nio.file.Path>,? extends R> block)

    - #### deleteIfExists

          public static boolean deleteIfExists(java.nio.file.Path $receiver)

    - #### readAll

          public static byte[] readAll(java.nio.file.Path $receiver)

    - #### read

          public static <R> R read(java.nio.file.Path $receiver,
                                   java.nio.file.OpenOption[] options,
                                   kotlin.jvm.functions.Function1<? super java.io.InputStream,? extends R> block)

    - #### write

          public static void write(java.nio.file.Path $receiver,
                                   boolean createDirs,
                                   java.nio.file.OpenOption[] options,
                                   kotlin.jvm.functions.Function1<? super java.io.OutputStream,kotlin.Unit> block)

    - #### readLines

          public static <R> R readLines(java.nio.file.Path $receiver,
                                        java.nio.charset.Charset charset,
                                        kotlin.jvm.functions.Function1<? super java.util.stream.Stream<java.lang.String>,? extends R> block)

    - #### writeLines

          public static java.nio.file.Path writeLines(java.nio.file.Path $receiver,
                                                      java.lang.Iterable<? extends java.lang.CharSequence> lines,
                                                      java.nio.charset.Charset charset,
                                                      java.nio.file.OpenOption options)

    - #### copyTo

          public static long copyTo(java.io.InputStream $receiver,
                                    java.nio.file.Path target,
                                    java.nio.file.CopyOption options)

    - #### until

          public static java.time.Duration until(java.time.temporal.Temporal $receiver,
                                                 java.time.temporal.Temporal endExclusive)

    - #### indexOfOrThrow

          public static <T> int indexOfOrThrow(java.util.List<? extends T> $receiver,
                                               T item)

      Returns the index of the given item or throws IllegalArgumentException if not found.

      See Also:
        IllegalArgumentException

    - #### noneOrSingle

          public static <T> T noneOrSingle(java.lang.Iterable<? extends T> $receiver,
                                           kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> predicate)

      Returns the single element matching the given predicate, or `null` if element was not found, or throws if more than one element was found.

    - #### noneOrSingle

          public static <T> T noneOrSingle(java.lang.Iterable<? extends T> $receiver)

      Returns single element, or `null` if element was not found, or throws if more than one element was found.

    - #### randomOrNull

          public static <T> T randomOrNull(java.util.List<? extends T> $receiver)

      Returns a random element in the list, or null if empty

    - #### randomOrNull

          public static <T> T randomOrNull(java.util.List<? extends T> $receiver,
                                           kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> predicate)

      Returns a random element in the list matching the given predicate, or null if none found

    - #### getRunOnCallerThread

          public static java.util.concurrent.Executor getRunOnCallerThread()

    - #### elapsedTime

          public static java.time.Duration elapsedTime(kotlin.jvm.functions.Function0<kotlin.Unit> block)

    - #### logElapsedTime

          public static <T> T logElapsedTime(java.lang.String label,
                                             org.slf4j.Logger logger,
                                             kotlin.jvm.functions.Function0<? extends T> body)

    - #### logElapsedTime

          public static <T> T logElapsedTime(org.slf4j.Logger $receiver,
                                             java.lang.String label,
                                             kotlin.jvm.functions.Function0<? extends T> body)

    - #### extractZipFile

          public static void extractZipFile(java.nio.file.Path zipFile,
                                            java.nio.file.Path toDirectory)

      Given a path to a zip file, extracts it to the given directory.

    - #### getRootCause

          public static java.lang.Throwable getRootCause(java.lang.Throwable $receiver)

    - #### bufferUntilSubscribed

          public static <T> rx.Observable<T> bufferUntilSubscribed(rx.Observable<T> $receiver)

      Returns an Observable that buffers events until subscribed.

    - #### tee

          public static <T> rx.Observer<T> tee(rx.Observer<T> $receiver,
                                               rx.Observer teeTo)

      Copy an Observer to multiple other Observers.

    - #### toFuture

          public static <T> com.google.common.util.concurrent.ListenableFuture<T> toFuture(rx.Observable<T> $receiver)

      Returns a ListenableFuture bound to the first item emitted by this Observable. The future will complete with a NoSuchElementException if no items are emitted or any other error thrown by the Observable. If it's cancelled then it will unsubscribe from the observable.

    - #### sum

          public static java.math.BigDecimal sum(java.lang.Iterable<? extends java.math.BigDecimal> $receiver)

      Return the sum of an Iterable of BigDecimals.

      See Also:
        BigDecimal

    - #### codePointsString

          public static java.lang.String codePointsString(int codePoints)