Remove old DependencyInjection#load method

This commit is contained in:
PepperCode1 2024-04-22 15:39:08 -07:00 committed by Jozufozu
parent 989728ca58
commit 0d53857f10

View file

@ -39,38 +39,4 @@ public final class DependencyInjection {
return apiClass.cast(implInstance); return apiClass.cast(implInstance);
} }
private static FlwApiLink load() {
Class<FlwApiLink> apiClass = FlwApiLink.class;
Class<?> implClass;
try {
implClass = Class.forName("com.jozufozu.flywheel.impl.FlwApiLinkImpl");
} catch (ReflectiveOperationException e) {
throw new RuntimeException("Could not find implementation", e);
}
if (!apiClass.isAssignableFrom(implClass)) {
throw new RuntimeException("Class %s does not implement interface %s"
.formatted(implClass.getName(), apiClass.getName()));
}
Constructor<?> implConstructor;
try {
implConstructor = implClass.getConstructor();
} catch (ReflectiveOperationException e) {
throw new RuntimeException("Could not find default constructor", e);
}
Object implInstance;
try {
implInstance = implConstructor.newInstance();
} catch (ReflectiveOperationException e) {
throw new RuntimeException("Could not instantiate implementation", e);
}
return apiClass.cast(implInstance);
}
} }