import java.util.Timer;
import java.util.TimerTask;
public class Debounce {
private Timer timer;
private long delay;
public Debounce(long delay) {
this.delay = delay;
this.timer = new Timer();
}
public void debounce(Runnable action) {
timer.cancel();
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
action.run();
}
}, delay);
}
}
public class UserInputProcessor {
private Debounce debounce;
public UserInputProcessor() {
}
public void processUserInput(String input) {
debounce.debounce(() -> {
});
}
}