public static boolean similarPackages ( String packName1 , String packName2 , int depth ) { if ( depth == 0 ) { return true ; } String dottedPackName1 = packName1 . replace ( ' ' , ' ' ) ; String dottedPackName2 = packName2 . replace ( ' ' , ' ' ) ; int dot1 = dottedPackName1 . indexOf ( ' ' ) ; int dot2 = dottedPackName2 . indexOf ( ' ' ) ; if ( dot1 < 0 ) { return ( dot2 < 0 ) ; } else if ( dot2 < 0 ) { return false ; } String s1 = dottedPackName1 . substring ( 0 , dot1 ) ; String s2 = dottedPackName2 . substring ( 0 , dot2 ) ; if ( ! s1 . equals ( s2 ) ) { return false ; } return similarPackages ( dottedPackName1 . substring ( dot1 + 1 ) , dottedPackName2 . substring ( dot2 + 1 ) , depth - 1 ) ; }
returns whether or not the two packages have the same first depth parts if they exist