aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Zajc <marko@zajc.eu.org>2023-08-07 03:55:50 +0200
committerMarko Zajc <marko@zajc.eu.org>2023-08-07 03:55:50 +0200
commit586ecbfac87318ea9fba2ae2fbd16f9aecf43059 (patch)
tree768a5b8fa2ec7b3365a266ce7d05bf34d4ed9d4f
parentafffe7282458d023e20e0178025eea0b00208871 (diff)
Remove a signature collision in EHandle
Handle methods for ESupplier<T, E> collided with Callable<T>. Opted to remove the former as an ESupplier can be cast to Callable.
-rw-r--r--src/main/java/com/github/markozajc/ef/EHandle.java82
1 files changed, 0 insertions, 82 deletions
diff --git a/src/main/java/com/github/markozajc/ef/EHandle.java b/src/main/java/com/github/markozajc/ef/EHandle.java
index 1a7da95..9285547 100644
--- a/src/main/java/com/github/markozajc/ef/EHandle.java
+++ b/src/main/java/com/github/markozajc/ef/EHandle.java
@@ -3188,88 +3188,6 @@ public class EHandle {
3188 * @return An exception-proofed function 3188 * @return An exception-proofed function
3189 */ 3189 */
3190 @Nonnull 3190 @Nonnull
3191 public static <T, E extends Throwable> Supplier<T> handle(@Nonnull ESupplier<T, E> handled,
3192 @Nonnull Function<Throwable, T> handler) {
3193 return () -> {
3194 try {
3195 return handled.getChecked();
3196 } catch (Throwable e) { // NOSONAR can't catch generic exceptions
3197 return handler.apply(e);
3198 }
3199 };
3200 }
3201
3202 /**
3203 * Handles any exception types that may occur in the handled supplier by throwing a
3204 * different exception.
3205 *
3206 * @param <E>
3207 * The handled function's exception type
3208 * @param <X>
3209 * The exception type to throw
3210 * @param handled
3211 * The function that may throw an exception
3212 * @param handler
3213 * The function handling exceptions
3214 *
3215 * @return An exception-proofed supplier
3216 *
3217 * @throws X
3218 * The exception returned by the handler
3219 */
3220 @Nonnull
3221 @SuppressWarnings({ "null", "unused" })
3222 public static <T, E extends Throwable, X extends Throwable> Supplier<T> handleThrowing(@Nonnull ESupplier<T, E> handled,
3223 @Nonnull Function<Throwable, X> handler) throws X {
3224 return () -> {
3225 try {
3226 return handled.getChecked();
3227 } catch (Throwable e) { // NOSONAR can't catch generic exceptions
3228 throw asUnchecked(handler.apply(e));
3229 }
3230 };
3231 }
3232
3233 /**
3234 * Handles any exception types that may occur in the handled supplier by throwing it
3235 * explicitly.
3236 *
3237 * @param <E>
3238 * The handled function's exception type
3239 * @param handled
3240 * The function that may throw an exception
3241 *
3242 * @return An exception-proofed supplier
3243 *
3244 * @throws E
3245 * The checked exception
3246 */
3247 @Nonnull
3248 @SuppressWarnings("unused")
3249 public static <T, E extends Throwable> Supplier<T> handleThrowing(@Nonnull ESupplier<T, E> handled) throws E {
3250 return () -> {
3251 try {
3252 return handled.getChecked();
3253 } catch (Throwable e) { // NOSONAR can't catch generic exceptions
3254 throw asUnchecked(e);
3255 }
3256 };
3257 }
3258
3259 /**
3260 * Handles a generic exception type that may occur in the handled function with a
3261 * provided handler.
3262 *
3263 * @param <E>
3264 * The handled function's exception type
3265 * @param handled
3266 * The function that may throw an exception
3267 * @param handler
3268 * The function handling exceptions
3269 *
3270 * @return An exception-proofed function
3271 */
3272 @Nonnull
3273 public static <E extends Throwable> BooleanSupplier handle(@Nonnull EBooleanSupplier<E> handled, 3191 public static <E extends Throwable> BooleanSupplier handle(@Nonnull EBooleanSupplier<E> handled,
3274 @Nonnull Predicate<Throwable> handler) { 3192 @Nonnull Predicate<Throwable> handler) {
3275 return () -> { 3193 return () -> {