src/main/java/de/vandermeer/execs/cf/CF.java
protected final Map<Class<?>, URI> searchDirectory(Class<?> clazz, File directory, URI location, String packageName){
		Map<Class<?>, URI> ret = new HashMap<>();

		String[] files = directory.list();
		for(int i=0; i<files.length; i++){
			if(files[i].endsWith(".class")){
				String classname = files[i].substring(0, files[i].length()-6);
				try{
					Class<?> c = Class.forName(packageName + "." + classname);
					if(clazz.isAssignableFrom(c) && !clazz.getName().equals(packageName + "." + classname)){
						ret.put(c, location);
					}
				}
				catch(Exception ex){
					errors.add(ex);
				}
			}
		}
		return ret;
	}
protected final Map<Class<?>, URI> searchDirectory(Class<?> clazz, File directory, URI location, String packageName){
		Map<Class<?>, URI> ret = new HashMap<>();

		String[] files = directory.list();
		for(int i=0; i<files.length; i++){
			if(files[i].endsWith(".class")){
				String classname = files[i].substring(0, files[i].length()-6);
				try{
					Class<?> c = Class.forName(packageName + "." + classname);
					if(clazz.isAssignableFrom(c) && !clazz.getName().equals(packageName + "." + classname)){
						ret.put(c, location);
					}
				}
				catch(Exception ex){
					errors.add(ex);
				}
			}
		}
		return ret;
	}
protected final Map < Class < ? > , URI > searchDirectory ( Class < ? > clazz , File directory , URI location , String packageName ) { Map < Class < ? > , URI > ret = new HashMap <> ( ) ; String [ ] files = directory . list ( ) ; for ( int i = 0 ; i < files . length ; i ++ ) { if ( files [ i ] . endsWith ( ".class" ) ) { String classname = files [ i ] . substring ( 0 , files [ i ] . length ( ) - 6 ) ; try { Class < ? > c = Class . forName ( packageName + "." + classname ) ; if ( clazz . isAssignableFrom ( c ) && ! clazz . getName ( ) . equals ( packageName + "." + classname ) ) { ret . put ( c , location ) ; } } catch ( Exception ex ) { errors . add ( ex ) ; } } } return ret ; }
Returns all known subclasses found in a given directory.
@param clazz class name to look for
@param directory search directory
@param location a URI location for return map
@param packageName a package name to test against class name
@return a map with found classes, empty if none found
Returns all known subclasses found in a given directory .