org.simpleflatmapper.reflect.impl.EmptyConstructorInstantiator Maven / Gradle / Ivy
package org.simpleflatmapper.reflect.impl;
import org.simpleflatmapper.reflect.Instantiator;
import org.simpleflatmapper.util.ErrorHelper;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
public final class EmptyConstructorInstantiator implements Instantiator {
private final Constructor constructor;
public EmptyConstructorInstantiator(final Constructor constructor) {
this.constructor = constructor;
}
@Override
public T newInstance(S s) throws Exception {
try {
return constructor.newInstance();
} catch(InvocationTargetException e) {
return ErrorHelper.rethrow(e.getCause());
}
}
@Override
public String toString() {
return "EmptyConstructorInstantiator{" +
"constructor=" + constructor +
'}';
}
}