1 package net.pterodactylus.rhynodge.engine;
3 import java.util.Optional;
5 import net.pterodactylus.rhynodge.Reaction;
6 import net.pterodactylus.rhynodge.State;
7 import net.pterodactylus.rhynodge.states.StateManager;
10 * Allows simple access to a {@link Reaction}’s saved states without exposing
11 * the key used to access the state on disk.
13 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
15 public class ReactionState {
17 private final StateManager stateManager;
18 private final String reactionName;
20 public ReactionState(StateManager stateManager, String reactionName) {
21 this.stateManager = stateManager;
22 this.reactionName = reactionName;
25 public Optional<State> loadLastState() {
26 return stateManager.loadLastState(reactionName);
29 public Optional<State> loadLastSuccessfulState() {
30 return stateManager.loadLastSuccessfulState(reactionName);
33 public void saveState(State state) {
34 stateManager.saveState(reactionName, state);