public final static boolean doesSequenceContainInvalidChar ( String sequence , Set < Character > cSet ) { for ( char c : sequence . toCharArray ( ) ) { if ( ! cSet . contains ( c ) ) return true ; } return false ; }
Checks if given sequence contains invalid characters . Returns true if invalid characters are found else return false . Note that any characters are deemed as valid only if it is found in cSet .