Toggle navigation
Home
java.lang.Class to java.util.Collection
No. of Instances - 4
No. of Commits - 3
No. of Projects - {'fastjson', 'sonarqube', 'atomix'}
Hierarchy/Composition: -
Primitive Info: -
NameSpace: Jdk -> Jdk
Mapping:
Add or Remove Method invocation
mappings.computeIfAbsent(new CacheKey(types),cacheKey -> { final String[] whitelistPackages=StringUtils.split(System.getProperty("io.atomix.whitelistPackages"),","); final ClassGraph classGraph=whitelistPackages != null ? new ClassGraph().enableClassInfo().whitelistPackages(whitelistPackages).addClassLoader(classLoader) : new ClassGraph().enableClassInfo().addClassLoader(classLoader); try (final ScanResult scanResult=classGraph.scan()){ final Map<Class<? extends NamedType>,Map<String,NamedType>> result=new ConcurrentHashMap<>(); for ( Class<? extends NamedType> type : cacheKey.types) { final Map<String,NamedType> tmp=new ConcurrentHashMap<>(); scanResult.getClassesImplementing(type.getName()).forEach(classInfo -> { if (classInfo.isInterface() || classInfo.isAbstract() || Modifier.isPrivate(classInfo.getModifiers())) { return; } final NamedType instance=newInstance(classInfo.loadClass()); final NamedType oldInstance=tmp.put(instance.name(),instance); if (oldInstance != null) { LOGGER.warn("Found multiple types with name={}, classes=[{}, {}]",instance.name(),oldInstance.getClass().getName(),instance.getClass().getName()); } } ); result.put(type,Collections.unmodifiableMap(tmp)); } return result; } } )
to
mappings.computeIfAbsent(new CacheKey(types.toArray(new Class[0])),cacheKey -> { final ClassGraph classGraph=!whitelistPackages.isEmpty() ? new ClassGraph().enableClassInfo().whitelistPackages(whitelistPackages.toArray(new String[0])).addClassLoader(classLoader) : new ClassGraph().enableClassInfo().addClassLoader(classLoader); try (final ScanResult scanResult=classGraph.scan()){ final Map<Class<? extends NamedType>,Map<String,NamedType>> result=new ConcurrentHashMap<>(); for ( Class<? extends NamedType> type : cacheKey.types) { final Map<String,NamedType> tmp=new ConcurrentHashMap<>(); scanResult.getClassesImplementing(type.getName()).forEach(classInfo -> { if (classInfo.isInterface() || classInfo.isAbstract() || Modifier.isPrivate(classInfo.getModifiers())) { return; } final NamedType instance=newInstance(classInfo.loadClass()); final NamedType oldInstance=tmp.put(instance.name(),instance); if (oldInstance != null) { LOGGER.warn("Found multiple types with name={}, classes=[{}, {}]",instance.name(),oldInstance.getClass().getName(),instance.getClass().getName()); } } ); result.put(type,Collections.unmodifiableMap(tmp)); } return result; } } )