public static < T > T findByClass ( Collection < ? > services , Class < T > clazz ) { for ( Object serv : services ) { if ( clazz . isInstance ( serv ) ) return clazz . cast ( serv ) ; } return null ; }
Finds a service in a collection of services based on its class .