All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.serenitybdd.screenplay.waits.WaitWithTimeout Maven / Gradle / Ivy

There is a newer version: 4.2.9
Show newest version
package net.serenitybdd.screenplay.waits;

import net.serenitybdd.screenplay.SilentInteraction;

import java.time.Duration;

public abstract class WaitWithTimeout extends SilentInteraction {
    protected Duration timeout;

    public TimeoutBuilder forNoMoreThan(long timeout) {
        return new TimeoutBuilder(timeout, this);
    }

    public  T forNoMoreThan(Duration timeout) {
        this.timeout = timeout;
        return (T) this;
    }

    public static class TimeoutBuilder implements WithTimeUnits {
        private final WaitWithTimeout waitWithTimeout;
        private final long duration;

        public TimeoutBuilder(long duration, WaitWithTimeout waitWithTimeout) {
            this.waitWithTimeout = waitWithTimeout;
            this.duration = duration;
        }

        @Override
        public WaitWithTimeout seconds() {
            waitWithTimeout.timeout = Duration.ofSeconds(duration);
            return waitWithTimeout;
        }

        @Override
        public WaitWithTimeout milliseconds() {
            waitWithTimeout.timeout = Duration.ofMillis(duration);
            return waitWithTimeout;
        }

        public WaitWithTimeout minutes() {
            waitWithTimeout.timeout = Duration.ofMinutes(duration);
            return waitWithTimeout;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy