@ SuppressWarnings ( "unchecked" ) public static < T > Optional < Class < T > > optional ( String dependency ) { try { return Optional . of ( ( Class < T > ) Class . forName ( dependency ) ) ; } catch ( ClassNotFoundException | NoClassDefFoundError e ) { return Optional . empty ( ) ; } }
Checks if a class exists in the classpath .