net.lenni0451.optconfig.access.impl.methodhandles.MethodHandleConstructorAccess Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of optconfig Show documentation
Show all versions of optconfig Show documentation
A java library for parsing yaml config files with support for comments and default values
The newest version!
package net.lenni0451.optconfig.access.impl.methodhandles;
import lombok.SneakyThrows;
import net.lenni0451.optconfig.access.impl.reflection.ReflectionConstructorAccess;
import net.lenni0451.optconfig.access.types.ConstructorAccess;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Constructor;
/**
* A default implementation of {@link ConstructorAccess} using method handles.
*/
public class MethodHandleConstructorAccess extends ReflectionConstructorAccess {
final MethodHandles.Lookup lookup;
public MethodHandleConstructorAccess(final MethodHandles.Lookup lookup, final Constructor> constructor) {
super(constructor);
this.lookup = lookup;
}
@Override
@SneakyThrows
public Object newInstance(Object... args) {
return this.lookup.unreflectConstructor(this.constructor).invokeWithArguments(args);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy