mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-09-06 15:58:20 +00:00
24 lines
743 B
Java
24 lines
743 B
Java
|
package com.sk89q.minecraft.util.commands;
|
||
|
|
||
|
import java.lang.reflect.Constructor;
|
||
|
import java.lang.reflect.InvocationTargetException;
|
||
|
|
||
|
public class SimpleInjector<T> implements Injector {
|
||
|
private final T injectionObject;
|
||
|
public SimpleInjector(T injectionObject) {
|
||
|
this.injectionObject = injectionObject;
|
||
|
}
|
||
|
|
||
|
public Object getInstance(Class<?> cls) throws InvocationTargetException,
|
||
|
IllegalAccessException, InstantiationException {
|
||
|
try {
|
||
|
Constructor<?> construct = cls.getConstructor(injectionObject.getClass());
|
||
|
return construct.newInstance(injectionObject);
|
||
|
} catch (NoSuchMethodException e) {
|
||
|
e.printStackTrace();
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
}
|