public <T extends AppState> T stateForId(String id, Class<T> stateClass) {
        T result = getState(id, stateClass);
        if (result == null) {
            throw new IllegalArgumentException("State not found for:" + id);
        }
        return stateClass.cast(result);
    }
Returns the state associated with the specified ID at the time it
 was attached or throws an IllegalArgumentException if the ID was
 not found.

@param <T> the desired type of AppState
@param id the AppState ID
@param stateClass the desired type of AppState
@return the pre-existing instance (not null)
jme3-core/src/main/java/com/jme3/app/state/AppStateManager.java