All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.atlassian.util.concurrent.ExceptionPolicy Maven / Gradle / Ivy

Go to download

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();
      }
    };
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy