org.simpleflatmapper.reflect.instantiator.ExecutableInstantiatorDefinition Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-reflect Show documentation
Show all versions of sfm-reflect Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.simpleflatmapper.reflect.instantiator;
import org.simpleflatmapper.reflect.InstantiatorDefinition;
import org.simpleflatmapper.reflect.Parameter;
import java.lang.reflect.Constructor;
import java.lang.reflect.Member;
import java.util.Arrays;
public final class ExecutableInstantiatorDefinition implements InstantiatorDefinition {
private final Member executable;
private final Parameter[] parameters;
private final Type type;
public ExecutableInstantiatorDefinition(Member executable,
Parameter... parameters) {
super();
this.executable = executable;
this.parameters = parameters;
this.type = executable instanceof Constructor ? Type.CONSTRUCTOR : Type.METHOD;
}
public Member getExecutable() {
return executable;
}
@Override
public Parameter[] getParameters() {
return parameters;
}
@Override
public boolean hasParam(Parameter param) {
for (Parameter p : parameters) {
if (p.equals(param)) {
return true;
}
}
return false;
}
@Override
public Type getType() {
return type;
}
@Override
public String getName() {
return executable.getName();
}
@Override
public String toString() {
return "InstantiatorDefinition{" +
"executable=" + executable +
", parameters=" + Arrays.toString(parameters) +
'}';
}
}