Class AbstractCloser<S,E extends Exception>

java.lang.Object
org.hibernate.search.util.common.impl.AbstractCloser<S,E>
Type Parameters:
E - The supertype of exceptions this object can catch.
Direct Known Subclasses:
Closer, SuppressingCloser

public abstract class AbstractCloser<S,E extends Exception> extends Object
A base class implementing the logic behind Closer and SuppressingCloser.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> S
    push(ClosingOperator<T,? extends E> operator, T objectToClose)
    If the given objectToClose is non-null, execute the given close operator immediately on objectToClose, swallowing any throwable in order to add it as suppressed to a previously caught throwable, or to re-throw it later.
    <T, U> S
    push(ClosingOperator<T,? extends E> operator, U objectToExtractFrom, Function<U,T> extract)
    If the given objectToExtractFrom is non-null, and an object can be extracted from it using extract, execute the given close operator immediately on the object to close, swallowing any throwable in order to add it as suppressed to a previously caught throwable, or to re-throw it later.
    <T, U> S
    pushAll(ClosingOperator<T,? extends E> operator, Iterable<? extends U> objectsToExtractFrom, Function<U,T> extract)
    Execute the given close operator immediately on an object extracted from each element of the given iterable, swallowing any throwable in order to add it as suppressed to a previously caught throwable, or to re-throw it later.
    <T> S
    pushAll(ClosingOperator<T,? extends E> operator, Iterable<T> objectsToClose)
    Execute the given close operator immediately on each element of the given iterable, swallowing any throwable in order to add it as suppressed to a previously caught throwable, or to re-throw it later.
    final <T> S
    pushAll(ClosingOperator<T,? extends E> operator, T... objectsToClose)
    Execute the given close operator immediately on each element of the given array, swallowing any throwable in order to add it as suppressed to a previously caught throwable, or to re-throw it later.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractCloser

      public AbstractCloser()
  • Method Details

    • push

      public <T> S push(ClosingOperator<T,? extends E> operator, T objectToClose)
      If the given objectToClose is non-null, execute the given close operator immediately on objectToClose, swallowing any throwable in order to add it as suppressed to a previously caught throwable, or to re-throw it later.
      Parameters:
      operator - An operator to close objectToClose. Accepts lambdas such as MyType::close.
      objectToClose - An object to close.
      Returns:
      this, for method chaining.
    • push

      public <T, U> S push(ClosingOperator<T,? extends E> operator, U objectToExtractFrom, Function<U,T> extract)
      If the given objectToExtractFrom is non-null, and an object can be extracted from it using extract, execute the given close operator immediately on the object to close, swallowing any throwable in order to add it as suppressed to a previously caught throwable, or to re-throw it later.
      Parameters:
      operator - An operator to close objectToClose. Accepts lambdas such as MyType::close.
      objectToExtractFrom - An object from which to extract the object to close.
      extract - A function to extract an object to close from objectToExtractFrom. Accepts lambdas such as MyType::get.
      Returns:
      this, for method chaining.
    • pushAll

      public <T> S pushAll(ClosingOperator<T,? extends E> operator, Iterable<T> objectsToClose)
      Execute the given close operator immediately on each element of the given iterable, swallowing any throwable in order to add it as suppressed to a previously caught throwable, or to re-throw it later.
      Parameters:
      operator - An operator to close each element in objectsToClose. Accepts lambdas such as MyType::close.
      objectsToClose - An iterable of objects to close.
      Returns:
      this, for method chaining.
    • pushAll

      public <T, U> S pushAll(ClosingOperator<T,? extends E> operator, Iterable<? extends U> objectsToExtractFrom, Function<U,T> extract)
      Execute the given close operator immediately on an object extracted from each element of the given iterable, swallowing any throwable in order to add it as suppressed to a previously caught throwable, or to re-throw it later.
      Parameters:
      operator - An operator to close each element in objectsToClose. Accepts lambdas such as MyType::close.
      objectsToExtractFrom - An iterable of objects from which to extract the objects to close.
      extract - A function to extract an object to close from the elements of objectsToExtractFrom. Accepts lambdas such as MyType::get.
      Returns:
      this, for method chaining.
    • pushAll

      @SafeVarargs public final <T> S pushAll(ClosingOperator<T,? extends E> operator, T... objectsToClose)
      Execute the given close operator immediately on each element of the given array, swallowing any throwable in order to add it as suppressed to a previously caught throwable, or to re-throw it later.
      Parameters:
      operator - An operator to close each element in objectsToClose. Accepts lambdas such as MyType::close.
      objectsToClose - An array of objects to close.
      Returns:
      this, for method chaining.