001/**
002 * Powerunit - A JDK1.8 test framework
003 * Copyright (C) 2014 Mathieu Boretti.
004 *
005 * This file is part of Powerunit
006 *
007 * Powerunit is free software: you can redistribute it and/or modify
008 * it under the terms of the GNU General Public License as published by
009 * the Free Software Foundation, either version 3 of the License, or
010 * (at your option) any later version.
011 *
012 * Powerunit is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015 * GNU General Public License for more details.
016 *
017 * You should have received a copy of the GNU General Public License
018 * along with Powerunit. If not, see <http://www.gnu.org/licenses/>.
019 */
020package ch.powerunit.extensions.async.lang;
021
022import java.util.concurrent.CompletableFuture;
023
024/**
025 * First Step of the builder of {@link CompletableFuture} to skip, if necessary,
026 * the error.
027 * 
028 * @param <T>
029 *            The type of result of the {@link CompletableFuture}
030 *
031 */
032public interface WaitResultBuilder1<T> extends WaitResultBuilder2<T> {
033
034        /**
035         * Ignore any error during execution of the callable and define if there are not
036         * result and an exception at last operation if this exception must be thrown.
037         * 
038         * @param alsoDontFailWhenNoResultAndException
039         *            true if the last exception must also be ignored
040         * @return {@link WaitResultBuilder2 the next step of the builder}
041         */
042        WaitResultBuilder2<T> ignoreException(boolean alsoDontFailWhenNoResultAndException);
043
044        /**
045         * Ignore any error during execution of the callable.
046         * 
047         * @return {@link WaitResultBuilder2 the next step of the builder}
048         */
049        default WaitResultBuilder2<T> ignoreException() {
050                return ignoreException(true);
051        }
052
053        /**
054         * Explicitly indicate that no exception must be ignored.
055         * <p>
056         * This this the normal behaviour. This method may be used to make it explicit
057         * in the code.
058         * <p>
059         * For example, the following code :
060         * 
061         * <pre>
062         * WaitResult.of(myCallable).dontIgnoreException().expecting(myPredicate).repeat(2)
063         *              .every(1000, TimeUnit.MILLISECONDS).get()
064         * </pre>
065         * 
066         * Throws an {@link AssertionError} if {@code myCallable} throws an exception.
067         * 
068         * @return {@link WaitResultBuilder2 the next step of the builder}
069         * @since 1.0.0
070         */
071        default WaitResultBuilder2<T> dontIgnoreException() {
072                return this;
073        }
074}