public static <T>T selectRandomItem(Set<T> items){
  checkNotNull(items,"Cannot selectRandomItem from null items");
  checkArgument(!items.isEmpty(),"Cannot selectRandomItem from empty items");
  randomGenerator.setSeed(System.currentTimeMillis());
  int selectedServerIndex=randomGenerator.nextInt(items.size());
  T item=null;
  Iterator<T> itemsIterator=items.iterator();
  for (int i=0; i <= selectedServerIndex && itemsIterator.hasNext(); i++) {
    item=itemsIterator.next();
  }
  return item;
}

public static < T > T selectRandomItem ( Set < T > items ) { checkNotNull ( items , "Cannot selectRandomItem from null items" ) ; checkArgument ( ! items . isEmpty ( ) , "Cannot selectRandomItem from empty items" ) ; randomGenerator . setSeed ( System . currentTimeMillis ( ) ) ; int selectedServerIndex = randomGenerator . nextInt ( items . size ( ) ) ; T item = null ; Iterator < T > itemsIterator = items . iterator ( ) ; for ( int i = 0 ; i <= selectedServerIndex && itemsIterator . hasNext ( ) ; i ++ ) { item = itemsIterator . next ( ) ; } return item ; }
randomly select one of the items .
