As you correctly say, the `super` keyword is a means to access the parent class. Roughly speaking, to construct an instance of a child object (e.g. Sleep in this case), an instance of the parent class also must be constructed (ConditionalSleep). If it did not do this, then how would you access the `sleep` method of ConditionalSleep? The `super` keyword when used in the constructor enables this: in this particular case, it will create an instance of the parent class with the `ConditionalSleep(int timeout)` constructor. It is clear that this is necessary as the ConditionalSleep class needs to know the duration of the sleep.
The `condition` method is actually used by the ConditionalSleep class. As you again rightly say, it is abstract, so though ConditionalSleep refers to it, it does not provide a concrete implementation. It is for this reason that ConditionalSleeps are commonly defined anonymously, e.g.:
new ConditionalSleep(3000) {
@Override
public boolean condition() {
return getCombat().isSpecialActivated();
}
}.sleep();
This class which you show simply provides a concrete implementation for the condition method, where a BooleanSupplier (supplied during construction) provides the return value.
It looks like this class is essentially pointless, other than perhaps to enable succinct code by working with BooleanSuppliers rather than anonymous instantiations. If it's easier to understand for you, i'd stick with anonymous instances, or you could create your own concrete sleep classes, e.g.:
public class RunSleep extends ConditionalSleep {
private final MethodProvider mp;
public RunSleep(MethodProvider mp, int timeout) {
super(timeout);
this.mp = mp;
}
@Override
public boolean condition() throws InterruptedException {
return mp.getSettings().isRunning();
}
}
Hopefully this is helpful, let me know if you're still stick or have any further questions, i'm always happy to help.
Good luck!
-Apa