All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.simpleflatmapper.reflect.instantiator.ExecutableInstantiatorDefinition Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 9.0.2
Show newest version
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) +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy