io.atlassian.util.concurrent.ExceptionPolicy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of atlassian-util-concurrent Show documentation
Show all versions of atlassian-util-concurrent Show documentation
This project contains utility classes that are used by
various products and projects inside Atlassian and may have some
utility to the world at large.
The newest version!
package io.atlassian.util.concurrent;
import java.util.function.Function;
import java.util.function.Supplier;
import static java.util.function.Function.identity;
/**
* Represents an exception handling policy. Default implementations can be found
* in {@link io.atlassian.util.concurrent.ExceptionPolicy.Policies}.
*/
public interface ExceptionPolicy {
/**
* Handle a supplier which may or may not throw an Exception.
*
* @param the return type of the Supplier
* @return the ExceptionPolicy handler
*/
Function, Supplier> handler();
/**
* Default exception handling policies
*/
enum Policies implements ExceptionPolicy {
IGNORE_EXCEPTIONS {
public Function, Supplier> handler() {
return Functions. ignoreExceptions();
}
},
THROW {
public Function, Supplier> handler() {
return identity();
}
};
}
}