public static String formatElementListString(Iterable<String> values,String oneElementMessage,String twoOrThreeElementsMessage,String moreThenThreeElementsMessage){
  int size=Iterables.size(values);
  if (size <= 1) {
    return String.format(oneElementMessage,Iterables.getFirst(values,"<validation error>"));
  }
 else   if (size <= 3) {
    return String.format(twoOrThreeElementsMessage,atMostTwo(values,size),Iterables.getLast(values));
  }
 else {
    return String.format(moreThenThreeElementsMessage,atMostTwo(values,size),size - 2);
  }
}

public static String formatElementListString ( Iterable < String > values , String oneElementMessage , String twoOrThreeElementsMessage , String moreThenThreeElementsMessage ) { int size = Iterables . size ( values ) ; if ( size <= 1 ) { return String . format ( oneElementMessage , Iterables . getFirst ( values , "<validation error>" ) ) ; } else if ( size <= 3 ) { return String . format ( twoOrThreeElementsMessage , atMostTwo ( values , size ) , Iterables . getLast ( values ) ) ; } else { return String . format ( moreThenThreeElementsMessage , atMostTwo ( values , size ) , size - 2 ) ; } }
formats a message picking the format string depending on number of arguments
