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

org.sfm.reflect.MethodSetter Maven / Gradle / Ivy

package org.sfm.reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public final class MethodSetter implements Setter {

	private final Method method;
	private final Class type;
	
	@SuppressWarnings("unchecked")
	public MethodSetter(final Method method) {
		this.method = method;
		this.type = (Class) method.getParameterTypes()[0];
	}

	public void set(final T target, final P value) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
		method.invoke(target, value);
	}

	@Override
	public Class getPropertyType() {
		return type;
	}
	
	public Method getMethod() {
		return method;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy