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

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

    • Method Detail

      • shouldLoadSync

         final Boolean shouldLoadSync()

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

      • stream

         InputStream stream()

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

      • bytes

         ByteArray bytes()

        Return this resource's contents as an array of bytes.

      • loadAsync

         final <T extends Any> Unit loadAsync(Function1<Throwable, Unit> errorHandler, Function1<ByteArray, 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 worker 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 worker 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<ByteArray, 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