-
- All Implemented Interfaces:
public final class ResourceKt
-
-
Method Summary
Modifier and Type Method Description final static Resourcefallback(Resource $self, Function1<Resource.Exception, Resource> fallbackResourceFactory)Falls back to alternative resources when the receiver fails. final static Resourcefallback(Resource $self, Resource fallbackResource)Falls back to the given alternative resource when the receiver fails. final static SynchronizedResourcesynchronized(Resource $self)Wraps this resource in a SynchronizedResource to protect the access from multiple threads. final static BufferingResourcebuffered(Resource $self, Long resourceLength, Long size)Wraps this resource in a BufferingResource to improve reading performances. final static <R extends Any, S extends Any> Try<R, Resource.Exception>mapCatching(Try<S, Resource.Exception> $self, Function1<S, R> transform)Maps the result with the given transformIf the transform throws an Exception, it is wrapped in a failure with Resource.Exception.Other. final static <R extends Any, S extends Any> Try<R, Resource.Exception>flatMapCatching(Try<S, Resource.Exception> $self, Function1<S, Try<R, Resource.Exception>> transform)-
-
Method Detail
-
fallback
final static Resource fallback(Resource $self, Function1<Resource.Exception, Resource> fallbackResourceFactory)
Falls back to alternative resources when the receiver fails.
-
fallback
final static Resource fallback(Resource $self, Resource fallbackResource)
Falls back to the given alternative resource when the receiver fails.
-
synchronized
final static SynchronizedResource synchronized(Resource $self)
Wraps this resource in a SynchronizedResource to protect the access from multiple threads.
-
buffered
final static BufferingResource buffered(Resource $self, Long resourceLength, Long size)
Wraps this resource in a BufferingResource to improve reading performances.
- Parameters:
resourceLength- The total length of the resource, when known.
-
mapCatching
final static <R extends Any, S extends Any> Try<R, Resource.Exception> mapCatching(Try<S, Resource.Exception> $self, Function1<S, R> transform)
Maps the result with the given transform
If the transform throws an Exception, it is wrapped in a failure with Resource.Exception.Other.
-
flatMapCatching
final static <R extends Any, S extends Any> Try<R, Resource.Exception> flatMapCatching(Try<S, Resource.Exception> $self, Function1<S, Try<R, Resource.Exception>> transform)
-
-
-
-