public void addPersistentState(BaseGameState state) { if (state == null) { throw new IllegalArgumentException("State must not be null!"); } if (persistentStates.containsKey(state.getClass())) { throw new IllegalStateException("A state of that class has already been added!"); } persistentStates.put(state.getClass(), state); }