public boolean attach(AppState state) {
        synchronized (states) {
            if (state.getId() != null && stateIndex.putIfAbsent(state.getId(), state) != null) {
                throw new IllegalArgumentException("ID:" + state.getId()
                        + " is already being used by another state:"
                        + stateIndex.get(state.getId()));
            }
            if (!states.contains(state) && !initializing.contains(state)) {
                state.stateAttached(this);
                initializing.add(state);
                return true;
            } else {
                return false;
            }
        }
    }
Attach a state to the AppStateManager, the same state cannot be attached
twice. Throws an IllegalArgumentException if the state has an ID and that
ID has already been associated with another AppState.

@param state The state to attach
@return True if the state was successfully attached, false if the state
was already attached.
jme3-core/src/main/java/com/jme3/app/state/AppStateManager.java