private static Class < ElasticsearchClient > findClass ( int version ) throws ClassNotFoundException { String className = "fr.pilato.elasticsearch.crawler.fs.client.v" + version + ".ElasticsearchClientV" + version ; logger . trace ( "Trying to find a class named [{}]" , className ) ; Class < ? > aClass = Class . forName ( className ) ; boolean isImplementingInterface = ElasticsearchClient . class . isAssignableFrom ( aClass ) ; if ( ! isImplementingInterface ) { throw new IllegalArgumentException ( "Class " + className + " does not implement " + ElasticsearchClient . class . getName ( ) + " interface" ) ; } return ( Class < ElasticsearchClient > ) aClass ; }
Try to load an ElasticsearchClient class