public <T> Collection<T> map(BiFunction<Message,MessageBatch,T> visitor) {
        Collection<T> retval=null;
        for(int i=0; i < index; i++) {
            try {
                T result=visitor.apply(messages[i], this);
                if(result != null) {
                    if(retval == null)
                        retval=new ArrayList<>();
                    retval.add(result);
                }
            }
            catch(Throwable t) {
            }
        }
        return retval;
    }
public < T > Collection < T > map ( BiFunction < Message , MessageBatch , T > visitor ) { Collection < T > retval = null ; for ( int i = 0 ; i < index ; i ++ ) { try { T result = visitor . apply ( messages [ i ] , this ) ; if ( result != null ) { if ( retval == null ) retval = new ArrayList < > ( ) ; retval . add ( result ) ; } } catch ( Throwable t ) { } } return retval ; }
Applies a function to all messages and returns a list of the function results