61 lines
1.3 KiB
Java
61 lines
1.3 KiB
Java
package ctbrec.ui.event;
|
|
|
|
import java.time.Instant;
|
|
import java.util.Objects;
|
|
|
|
import ctbrec.Model;
|
|
import ctbrec.ui.JavaFxModel;
|
|
|
|
public class PlayerStartedEvent {
|
|
|
|
private Model model;
|
|
private Instant timestamp;
|
|
|
|
public PlayerStartedEvent(Model model) {
|
|
this(model, Instant.now());
|
|
}
|
|
|
|
public PlayerStartedEvent(Model model, Instant timestamp) {
|
|
this.model = unwrap(model);
|
|
this.timestamp = timestamp;
|
|
}
|
|
|
|
public Model getModel() {
|
|
return model;
|
|
}
|
|
|
|
public Instant getTimestamp() {
|
|
return timestamp;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return Objects.hash(timestamp);
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if (this == obj)
|
|
return true;
|
|
if (obj == null)
|
|
return false;
|
|
if (getClass() != obj.getClass())
|
|
return false;
|
|
PlayerStartedEvent other = (PlayerStartedEvent) obj;
|
|
return Objects.equals(timestamp, other.timestamp);
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "PlayerStartedEvent [model=" + model + ", timestamp=" + timestamp + "]";
|
|
}
|
|
|
|
private Model unwrap(Model model) {
|
|
if (model instanceof JavaFxModel) {
|
|
return ((JavaFxModel) model).getDelegate();
|
|
} else {
|
|
return model;
|
|
}
|
|
}
|
|
}
|