/** * Execute the given close {@code operator} <strong>immediately</strong> on * each element of the given iterable, swallowing any throwable in order to * {@link Throwable#addSuppressed(Throwable) add it as suppressed} to a previously caught throwable, * or to re-throw it later. * @param operator An operator to close each element in {@code objectsToClose}. Accepts lambdas * such as {@code MyType::close}. * @param objectsToClose An iterable of objects to close. * @return {@code this}, for method chaining. */ public <T> S pushAll(ClosingOperator<T, ? extends E> operator, Iterable<T> objectsToClose) { for ( T objectToClose : objectsToClose ) { push( operator, objectToClose ); } return getSelf(); }
/** * Execute the given close {@code operator} <strong>immediately</strong> on * each element of the given array, swallowing any throwable in order to * {@link Throwable#addSuppressed(Throwable) add it as suppressed} to a previously caught throwable, * or to re-throw it later. * @param operator An operator to close each element in {@code objectsToClose}. Accepts lambdas * such as {@code MyType::close}. * @param objectsToClose An array of objects to close. * @return {@code this}, for method chaining. */ @SafeVarargs public final <T> S pushAll(ClosingOperator<T, ? extends E> operator, T ... objectsToClose) { for ( T objectToClose : objectsToClose ) { push( operator, objectToClose ); } return getSelf(); }