private static < T > T after ( T target , Iterable < ? extends T > iterable , T defaultValue ) { Iterator < ? extends T > iterator = iterable . iterator ( ) ; while ( iterator . hasNext ( ) ) { if ( iterator . next ( ) . equals ( target ) ) { break ; } } if ( iterator . hasNext ( ) ) { return iterator . next ( ) ; } return defaultValue ; }
Find the element in the iterable following the target