static void removeLogicalDuplicates ( SortedSet < String > packages ) { Iterator < String > iterator = packages . iterator ( ) ; if ( ! iterator . hasNext ( ) ) { return ; } String last = iterator . next ( ) ; while ( iterator . hasNext ( ) ) { String current = iterator . next ( ) ; if ( current . startsWith ( last ) ) { iterator . remove ( ) ; } else { last = current ; } } }
Traverses sorted list of packages and removes logical duplicates . For example if the set contains akka . akka . io . and akka . util . only akka . will remain . Note that if the set contains only akka . io . and akka . util . both will remain . Otherwise all of the org . apache . would devolve to org .