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 behindCloserandSuppressingCloser.
-
-
Constructor Summary
Constructors Constructor Description AbstractCloser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Spush(ClosingOperator<T,? extends E> operator, T objectToClose)If the givenobjectToCloseis non-null, execute the given closeoperatorimmediately onobjectToClose, swallowing any throwable in order toadd it as suppressedto a previously caught throwable, or to re-throw it later.<T,U>
Spush(ClosingOperator<T,? extends E> operator, U objectToExtractFrom, Function<U,T> extract)If the givenobjectToExtractFromis non-null, and an object can be extracted from it usingextract, execute the given closeoperatorimmediately on the object to close, swallowing any throwable in order toadd it as suppressedto a previously caught throwable, or to re-throw it later.<T,U>
SpushAll(ClosingOperator<T,? extends E> operator, Iterable<? extends U> objectsToExtractFrom, Function<U,T> extract)Execute the given closeoperatorimmediately on an object extracted from each element of the given iterable, swallowing any throwable in order toadd it as suppressedto a previously caught throwable, or to re-throw it later.<T> SpushAll(ClosingOperator<T,? extends E> operator, Iterable<T> objectsToClose)Execute the given closeoperatorimmediately on each element of the given iterable, swallowing any throwable in order toadd it as suppressedto a previously caught throwable, or to re-throw it later.<T> SpushAll(ClosingOperator<T,? extends E> operator, T... objectsToClose)Execute the given closeoperatorimmediately on each element of the given array, swallowing any throwable in order toadd it as suppressedto a previously caught throwable, or to re-throw it later.
-
-
-
Method Detail
-
push
public <T> S push(ClosingOperator<T,? extends E> operator, T objectToClose)
If the givenobjectToCloseis non-null, execute the given closeoperatorimmediately onobjectToClose, swallowing any throwable in order toadd it as suppressedto a previously caught throwable, or to re-throw it later.- Parameters:
operator- An operator to closeobjectToClose. Accepts lambdas such asMyType::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 givenobjectToExtractFromis non-null, and an object can be extracted from it usingextract, execute the given closeoperatorimmediately on the object to close, swallowing any throwable in order toadd it as suppressedto a previously caught throwable, or to re-throw it later.- Parameters:
operator- An operator to closeobjectToClose. Accepts lambdas such asMyType::close.objectToExtractFrom- An object from which to extract the object to close.extract- A function to extract an object to close fromobjectToExtractFrom. Accepts lambdas such asMyType::get.- Returns:
this, for method chaining.
-
pushAll
public <T> S pushAll(ClosingOperator<T,? extends E> operator, Iterable<T> objectsToClose)
Execute the given closeoperatorimmediately on each element of the given iterable, swallowing any throwable in order toadd it as suppressedto a previously caught throwable, or to re-throw it later.- Parameters:
operator- An operator to close each element inobjectsToClose. Accepts lambdas such asMyType::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 closeoperatorimmediately on an object extracted from each element of the given iterable, swallowing any throwable in order toadd it as suppressedto a previously caught throwable, or to re-throw it later.- Parameters:
operator- An operator to close each element inobjectsToClose. Accepts lambdas such asMyType::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 ofobjectsToExtractFrom. Accepts lambdas such asMyType::get.- Returns:
this, for method chaining.
-
pushAll
@SafeVarargs public final <T> S pushAll(ClosingOperator<T,? extends E> operator, T... objectsToClose)
Execute the given closeoperatorimmediately on each element of the given array, swallowing any throwable in order toadd it as suppressedto a previously caught throwable, or to re-throw it later.- Parameters:
operator- An operator to close each element inobjectsToClose. Accepts lambdas such asMyType::close.objectsToClose- An array of objects to close.- Returns:
this, for method chaining.
-
-