public Collection < String > split ( ) { String s = ident ; Set < String > result = new HashSet <> ( ) ; while ( s . length ( ) > 0 ) { StringBuilder buf = new StringBuilder ( ) ; char first = s . charAt ( 0 ) ; buf . append ( first ) ; int i = 1 ; if ( s . length ( ) > 1 ) { boolean camelWord ; if ( Character . isLowerCase ( first ) ) { camelWord = true ; } else { char next = s . charAt ( i ++ ) ; buf . append ( next ) ; camelWord = Character . isLowerCase ( next ) ; } while ( i < s . length ( ) ) { char c = s . charAt ( i ) ; if ( Character . isUpperCase ( c ) ) { if ( camelWord ) { break ; } } else if ( ! camelWord ) { break ; } buf . append ( c ) ; ++ i ; } if ( ! camelWord && i < s . length ( ) ) { buf . deleteCharAt ( buf . length ( ) - 1 ) ; -- i ; } } result . add ( buf . toString ( ) . toLowerCase ( Locale . US ) ) ; s = s . substring ( i ) ; } return result ; }
Split the identifier into words .