static < T > Iterable < T > annotateEmptyStrings ( Iterable < T > items ) { if ( Iterables . contains ( items , "" ) ) { List < T > annotatedItems = Lists . newArrayList ( ) ; for ( T item : items ) { if ( Objects . equal ( item , "" ) ) { // This is a safe cast because know that at least one instance of T (this item) is a // String. @ SuppressWarnings ( "unchecked" ) T newItem = ( T ) HUMAN_UNDERSTANDABLE_EMPTY_STRING ; annotatedItems . add ( newItem ) ; } else { annotatedItems . add ( item ) ; } } return annotatedItems ; } else { return items ; } }
Returns an iterable with all empty strings replaced by a non - empty human understandable indicator for an empty string .