public <T extends AppState> T getState(String id, Class<T> stateClass) {
        return stateClass.cast(stateIndex.get(id));
    }
Returns the state associated with the specified ID at the time it was
attached or null if not state was attached with that ID.

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