@ SafeVarargs public static < T extends ParseTreeListener > T create ( Class < T > type , T ... delegates ) { ImmutableList < T > listeners = ImmutableList . copyOf ( delegates ) ; return Reflection . newProxy ( type , new AbstractInvocationHandler ( ) { @ Override @ ParametersAreNonnullByDefault protected Object handleInvocation ( Object proxy , Method method , Object [ ] args ) throws Throwable { for ( T listener : listeners ) { method . invoke ( listener , args ) ; } return null ; } @ Override public String toString ( ) { return MoreObjects . toStringHelper ( "CompositeParseTreeListener" ) . add ( "listeners" , listeners ) . toString ( ) ; } } ) ; }
Create new composite listener for a collection of delegates .