private static void buildAndDisplayAdUnitTree ( AdUnit root , List < AdUnit > adUnits ) { Map < String , List < AdUnit > > treeMap = new HashMap < String , List < AdUnit > > ( ) ; for ( AdUnit adUnit : adUnits ) { if ( adUnit . getParentId ( ) != null ) { if ( treeMap . get ( adUnit . getParentId ( ) ) == null ) { treeMap . put ( adUnit . getParentId ( ) , new ArrayList < AdUnit > ( ) ) ; } treeMap . get ( adUnit . getParentId ( ) ) . add ( adUnit ) ; } } if ( root != null ) { displayInventoryTree ( root , treeMap ) ; } else { System . out . println ( "No root unit found." ) ; } }
Builds and displays an ad unit tree from ad units underneath the root ad unit .