public class Sleep extends ConditionalSleep {
private BooleanSupplier condition;
public Sleep(BooleanSupplier condition, int timeout) {
super(timeout);
this.condition = condition;
}
@Override
public boolean condition() throws InterruptedException {
return condition.getAsBoolean();
}
public static boolean sleepUntil(BooleanSupplier condition, int timeout) {
return new Sleep(condition, timeout).sleep();
}
}
I got this class from a tutorial, but I'm trying to understand it and have a few questions:
What does super(timeout) do? I know super calls the parent class but what exactly does it do in this context?
What does the condition() method do in this class? It's an abstract method so it has to be implemented, but I don't see it being used for anything in this class, so why is return condition.getAsBoolean() necessary?