MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / Event

Class Event

innerclasses/controller/Event.java:9–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7import java.time.*; // Java 8 time classes
8
9public abstract class Event {
10 private Instant eventTime;
11 protected final Duration delayTime;
12 public Event(long millisecondDelay) {
13 delayTime = Duration.ofMillis(millisecondDelay);
14 start();
15 }
16 public void start() { // Allows restarting
17 eventTime = Instant.now().plus(delayTime);
18 }
19 public boolean ready() {
20 return Instant.now().isAfter(eventTime);
21 }
22 public abstract void action();
23}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected