![JAR search and dependency download from the Maven repository](/logo.png)
org.sfm.reflect.impl.InjectStaticMethodInstantiator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simpleFlatMapper Show documentation
Show all versions of simpleFlatMapper Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.sfm.reflect.impl;
import org.sfm.reflect.Getter;
import org.sfm.reflect.Instantiator;
import org.sfm.reflect.InstantiatorDefinition;
import org.sfm.reflect.Parameter;
import java.lang.reflect.Method;
import java.util.Map;
public final class InjectStaticMethodInstantiator implements Instantiator {
private final Method method;
private final Class> declaringClass;
private final ArgumentBuilder argBuilder;
private final InstantiatorDefinition instantiatorDefinition;
public InjectStaticMethodInstantiator(InstantiatorDefinition instantiatorDefinition, Map> injections) {
this.argBuilder = new ArgumentBuilder(instantiatorDefinition, injections);
this.method = (Method) instantiatorDefinition.getExecutable();
this.declaringClass = method.getDeclaringClass();
this.instantiatorDefinition = instantiatorDefinition;
}
@SuppressWarnings("unchecked")
@Override
public T newInstance(S s) throws Exception {
return (T) method.invoke(declaringClass, argBuilder.build(s));
}
@Override
public String toString() {
return "InjectStaticMethodInstantiator{" +
"instantiatorDefinition=" + instantiatorDefinition +
'}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy