@SuppressWarnings("unchecked") public static <T>T findValueOfType(Collection<?> collection,Class<T> type){
  if (isEmpty(collection)) {
    return null;
  }
  T value=null;
  for (  Object element : collection) {
    if (type == null || type.isInstance(element)) {
      if (value != null) {
        return null;
      }
      value=(T)element;
    }
  }
  return value;
}

@ SuppressWarnings ( "unchecked" ) public static < T > T findValueOfType ( Collection < ? > collection , Class < T > type ) { if ( isEmpty ( collection ) ) { return null ; } T value = null ; for ( Object element : collection ) { if ( type == null || type . isInstance ( element ) ) { if ( value != null ) { return null ; } value = ( T ) element ; } } return value ; }
find a single value of the given type in the given collection .
