Source:
static Object getPluginImplementationViaProperty(Class<?> pluginClass, Properties props) { String classSimpleName = pluginClass.getSimpleName(); String defaultKey = "rxjava.plugin." + classSimpleName + ".implementation"; String implementingClass = props.getProperty(defaultKey); for (Map.Entry<Object, Object> e : props.entrySet()) { String key = e.getKey().toString(); if (key.startsWith("rxjava.plugin.") && key.endsWith(".class")) { String value = e.getValue().toString(); if (classSimpleName.equals(value)) { String index = key.substring(0, key.length() - 6).substring(14); String implKey = "rxjava.plugin." + index + ".impl"; implementingClass = props.getProperty(implKey); break; } } } if (implementingClass != null) { try { Class<?> cls = Class.forName(implementingClass); cls = cls.asSubclass(pluginClass); return cls.newInstance(); } catch (ClassCastException e) { throw new RuntimeException(classSimpleName + " implementation is not an instance of " + classSimpleName + ": " + implementingClass); } catch (ClassNotFoundException e) { throw new RuntimeException(classSimpleName + " implementation class not found: " + implementingClass, e); } catch (InstantiationException e) { throw new RuntimeException(classSimpleName + " implementation not able to be instantiated: " + implementingClass, e); } catch (IllegalAccessException e) { throw new RuntimeException(classSimpleName + " implementation not able to be accessed: " + implementingClass, e); } } return null; }

Target:
static Object getPluginImplementationViaProperty(Class<?> pluginClass, Properties props) { final String classSimpleName = pluginClass.getSimpleName(); final String pluginPrefix = "rxjava.plugin."; String defaultKey = pluginPrefix + classSimpleName + ".implementation"; String implementingClass = props.getProperty(defaultKey); if (implementingClass == null) { final String classSuffix = ".class"; final String implSuffix = ".impl"; for (Map.Entry<Object, Object> e : props.entrySet()) { String key = e.getKey().toString(); if (key.startsWith(pluginPrefix) && key.endsWith(classSuffix)) { String value = e.getValue().toString(); if (classSimpleName.equals(value)) { String index = key.substring(0, key.length() - classSuffix.length()).substring(pluginPrefix.length()); String implKey = pluginPrefix + index + implSuffix; implementingClass = props.getProperty(implKey); if (implementingClass == null) { throw new RuntimeException("Implementing class declaration for " + classSimpleName + " missing: " + implKey); } break; } } } } if (implementingClass != null) { try { Class<?> cls = Class.forName(implementingClass); cls = cls.asSubclass(pluginClass); return cls.newInstance(); } catch (ClassCastException e) { throw new RuntimeException(classSimpleName + " implementation is not an instance of " + classSimpleName + ": " + implementingClass); } catch (ClassNotFoundException e) { throw new RuntimeException(classSimpleName + " implementation class not found: " + implementingClass, e); } catch (InstantiationException e) { throw new RuntimeException(classSimpleName + " implementation not able to be instantiated: " + implementingClass, e); } catch (IllegalAccessException e) { throw new RuntimeException(classSimpleName + " implementation not able to be accessed: " + implementingClass, e); } } return null; }