Class Resource
-
- All Implemented Interfaces:
public class Resourcerepresentation of a resource, which can be loaded asynchronously or synchronously.
For the definition of a resource, see getResourceStream.
- Since:
1.1.6
-
-
Field Summary
Fields Modifier and Type Field Description private final StringresourcePathprivate final BooleanloadSync
-
Method Summary
Modifier and Type Method Description final StringgetResourcePath()final BooleangetLoadSync()trueif this resource should be loaded synchronously,falseotherwise.final <T extends Any> UnitloadAsync(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. final UnitloadAsync(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. final UnitloadAsyncDirect(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. final UnitloadAsyncDirectNT(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. final <T extends Any> Tload(Function1<Throwable, T> errorHandler, Function1<InputStream, T> mapper)load the given resource synchronously, mapping to definitely non-nullable type T. final ByteArrayload(Function1<Throwable, ByteArray> errorHandler)load the given resource synchronously into a new byte array. final ByteBufferloadDirect(Function1<Throwable, ByteBuffer> errorHandler)load the given resource synchronously into a new direct byte buffer. final ByteBufferloadDirectNT(Function1<Throwable, ByteBuffer> errorHandler)load the given resource synchronously into a new direct byte buffer, with null termination. final InputStreamstream()return the stream of this resource. StringtoString()IntegerhashCode()Booleanequals(Object other)-
-
Method Detail
-
getResourcePath
final String getResourcePath()
-
getLoadSync
final Boolean getLoadSync()
trueif this resource should be loaded synchronously,falseotherwise. (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.
-
-
-
-