forked from aws-samples/eb-java-scorekeep
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStateFactory.java
More file actions
25 lines (20 loc) · 835 Bytes
/
StateFactory.java
File metadata and controls
25 lines (20 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package scorekeep;
import java.util.*;
import java.lang.Exception;
public class StateFactory {
private final StateModel model = new StateModel();
public StateFactory(){
}
public State newState(String sessionId, String gameId, String stateText, Set<String> turn) throws SessionNotFoundException, GameNotFoundException {
String id = Identifiers.random();
State state = new State(id, sessionId, gameId, stateText, turn);
model.saveState(state);
return state;
}
public State getState(String sessionId, String gameId, String stateId) throws SessionNotFoundException, StateNotFoundException {
return model.loadState(stateId);
}
public List<State> getStates(String sessionId, String gameId) throws SessionNotFoundException, GameNotFoundException {
return model.loadStates(sessionId, gameId);
}
}