navigation/common/src/main/java/androidx/navigation/NavGraph.java
public void addDestination(@NonNull NavDestination node) {
        if (node.getId() == 0) {
            throw new IllegalArgumentException("Destinations must have an id."
                    + " Call setId() or include an android:id in your navigation XML.");
        }
        NavDestination existingDestination = mNodes.get(node.getId());
        if (existingDestination == node) {
            return;
        }
        if (node.getParent() != null) {
            throw new IllegalStateException("Destination already has a parent set."
                    + " Call NavGraph.remove() to remove the previous parent.");
        }
        if (existingDestination != null) {
            existingDestination.setParent(null);
        }
        node.setParent(this);
        mNodes.put(node.getId(), node);
    }
/**
     * Adds a destination to this NavGraph. The destination must have an
     * {@link NavDestination#getId()} id} set.
     *
     * <p>The destination must not have a {@link NavDestination#getParent() parent} set. If
     * the destination is already part of a {@link NavGraph navigation graph}, call
     * {@link #remove(NavDestination)} before calling this method.</p>
     *
     * @param node destination to add
     */
Adds a destination to this NavGraph. The destination must have an
NavDestination#getId() id} set.

The destination must not have a  NavDestination#getParent() parent set. If
the destination is already part of a  NavGraph navigation graph, call
#remove(NavDestination) before calling this method.

@param node destination to add
Adds a destination to this NavGraph . The destination must have an NavDestination#getId () id } set . The destination must not have a NavDestination#getParent () parent set . If the destination is already part of a NavGraph navigation graph call #remove ( NavDestination ) before calling this method . @param node destination to add
public void addDestination(@NonNull NavDestination node) {
        if (node.getId() == 0) {
            throw new IllegalArgumentException("Destinations must have an id."
                    + " Call setId() or include an android:id in your navigation XML.");
        }
        NavDestination existingDestination = mNodes.get(node.getId());
        if (existingDestination == node) {
            return;
        }
        if (node.getParent() != null) {
            throw new IllegalStateException("Destination already has a parent set."
                    + " Call NavGraph.remove() to remove the previous parent.");
        }
        if (existingDestination != null) {
            existingDestination.setParent(null);
        }
        node.setParent(this);
        mNodes.put(node.getId(), node);
    }
public void addDestination ( @ NonNull NavDestination node ) { if ( node . getId ( ) == 0 ) { throw new IllegalArgumentException ( "Destinations must have an id." + " Call setId() or include an android:id in your navigation XML." ) ; } NavDestination existingDestination = mNodes . get ( node . getId ( ) ) ; if ( existingDestination == node ) { return ; } if ( node . getParent ( ) != null ) { throw new IllegalStateException ( "Destination already has a parent set." + " Call NavGraph.remove() to remove the previous parent." ) ; } if ( existingDestination != null ) { existingDestination . setParent ( null ) ; } node . setParent ( this ) ; mNodes . put ( node . getId ( ) , node ) ; }
Adds a destination to this NavGraph.
Adds a destination to this NavGraph .