package io.fluentlenium.core.hook.wait;

import io.fluentlenium.core.hook.Hook;
import io.fluentlenium.core.hook.HookOptions;
import io.fluentlenium.core.wait.FluentWait;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.concurrent.TimeUnit;

/**
 * Annotation to enable the Wait Hook.
 *
 * @see WaitHook
 * @see WaitHookOptions
 */
@Inherited
@Target({ElementType.FIELD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Hook(WaitHook.class)
@HookOptions(WaitHookOptions.class)
public @interface Wait {
    /**
     * Maximum amount of time to wait before throwing a {@link org.openqa.selenium.TimeoutException}.
     *
     * @return timeout value
     */
    long timeout() default 5000L;

    /**
     * Time unit used for timeout value.
     *
     * @return time unit
     */
    TimeUnit timeUnit() default TimeUnit.MILLISECONDS;

    /**
     * Time interval to wait between each condition check.
     *
     * @return polling interval value
     */
    long pollingInterval() default 500L;

    /**
     * Time unit used for polling interval.
     *
     * @return time unit
     */
    TimeUnit pollingTimeUnit() default TimeUnit.MILLISECONDS;

    /**
     * Enable this option to disable default exceptions from {@link FluentWait}.
     *
     * @return boolean
     */
    boolean withNoDefaultsException() default false;

    /**
     * Throwables that will be ignored while waiting for a condition.
     *
     * @return array of ignored throwable
     */
    Class<? extends Throwable>[] ignoreAll() default {};
}
