exception handling during mount/unmount/reveal operations

This commit is contained in:
Sebastian Stenzel
2016-01-27 14:46:48 +01:00
parent c56d0b7d4a
commit 091a44e65d
20 changed files with 94 additions and 56 deletions
@@ -0,0 +1,8 @@
package org.cryptomator.common;
@FunctionalInterface
public interface ConsumerThrowingException<T, E extends Exception> {
void accept(T t) throws E;
}
@@ -0,0 +1,17 @@
package org.cryptomator.common;
import java.util.Optional;
public final class Optionals {
private Optionals() {
}
public static <T, E extends Exception> void ifPresent(Optional<T> optional, ConsumerThrowingException<T, E> consumer) throws E {
final T t = optional.orElse(null);
if (t != null) {
consumer.accept(t);
}
}
}