@ SuppressWarnings ( "unchecked" ) protected HashSet < String > getSetOfStrings ( Object strings ) { try { return ( HashSet < String > ) strings ; } catch ( ClassCastException ex ) { Collection < String > list = ( Collection < String > ) strings ; return new HashSet < String > ( list ) ; } }
Converts the given object into a set of strings . The object must either be a HashSet already or a different collection type .