Class Resource

  • All Implemented Interfaces:

    
    public class Resource
    
                        

    representation of a resource, which can be loaded asynchronously or synchronously.

    For the definition of a resource, see getResourceStream.

    Since:

    1.1.6

    • Constructor Detail

    • Method Detail

      • shouldLoadSync

         final Boolean shouldLoadSync()

        true if this resource should be loaded synchronously, false otherwise. (optional operation)

      • loadAsync

         final <T extends Any> Unit loadAsync(Function1<Throwable, Unit> errorHandler, Function1<InputStream, T> mapper, Function1<T, Unit> consumer)

        load the given resource asynchronously, mapping to definitely non-nullable type T, calling the consumer with the result on the main thread.

        In case of failure, the errorHandler will be called with the exception.

        Since:

        1.1.6

      • loadAsync

         final Unit loadAsync(Function1<Throwable, Unit> errorHandler, Function1<ByteArray, Unit> consumer)

        load the given resource asynchronously into a new byte array, calling the consumer with the result on the main thread.

        In case of failure, the errorHandler will be called with the exception.

        Since:

        1.1.6

      • loadAsyncDirect

         final Unit loadAsyncDirect(Function1<Throwable, Unit> errorHandler, Function1<ByteBuffer, Unit> consumer)

        load the given resource asynchronously into a new direct byte buffer, calling the consumer with the result on the main thread.

        In case of failure, the errorHandler will be called with the exception.

        Since:

        1.1.6

      • loadAsyncDirectNT

         final Unit loadAsyncDirectNT(Function1<Throwable, Unit> errorHandler, Function1<ByteBuffer, Unit> consumer)

        load the given resource asynchronously into a new direct byte buffer, with null termination, calling the consumer with the result on the main thread.

        In case of failure, the errorHandler will be called with the exception.

        Since:

        1.1.6

      • load

         final <T extends Any> T load(Function1<Throwable, T> errorHandler, Function1<InputStream, T> mapper)

        load the given resource synchronously, mapping to definitely non-nullable type T. you may then perform any operations on the result.

        In case of failure, the errorHandler will be called with the exception.

        Since:

        1.1.6

      • load

         final ByteArray load(Function1<Throwable, ByteArray> errorHandler)

        load the given resource synchronously into a new byte array. you may then perform any operations on the result.

        In case of failure, the errorHandler will be called with the exception.

        Since:

        1.1.6

      • loadDirect

         final ByteBuffer loadDirect(Function1<Throwable, ByteBuffer> errorHandler)

        load the given resource synchronously into a new direct byte buffer. you may then perform any operations on the result.

        In case of failure, the errorHandler will be called with the exception.

        Since:

        1.1.6

      • loadDirectNT

         final ByteBuffer loadDirectNT(Function1<Throwable, ByteBuffer> errorHandler)

        load the given resource synchronously into a new direct byte buffer, with null termination. you may then perform any operations on the result.

        In case of failure, the errorHandler will be called with the exception.

        Since:

        1.1.6

      • stream

        @ApiStatus.Obsolete(since = "1.1.6") final InputStream stream()

        return the stream of this resource. it is the caller's responsibility to close the stream.