class SimpleStateManager implements StateManager {

    @Override
    public boolean stateExistsForUser(Resource stateId, String username) {
        User user = engineManager.retrieveUser(username).orElseThrow(() ->
                new IllegalArgumentException("User not found"));
        try (RepositoryConnection conn = repository.getConnection()) {
            if (!stateExists(stateId, conn)) {
                throw new IllegalArgumentException("State not found");
            }
            return conn.getStatements(stateId, factory.createIRI(State.forUser_IRI),
                    user.getResource()).hasNext();
        }
    }

}