package br.com.reflector.api.dsl.clazz;

import java.lang.reflect.Method;

import br.com.reflector.api.exception.ReflectorException;

public class ReflectorMethod {

	private Method method;

	protected ReflectorMethod(final Class<?> clazz, final String name) {
		try {
			this.method = clazz.getDeclaredMethod(name);
		} catch (NoSuchMethodException e) {
			throw new ReflectorException("No such method " + name, e.getCause());
		} catch (SecurityException e) {
			throw new ReflectorException("Could not invoke method " + name, e.getCause());
		}
	}

	/**
	 * Create a class from methods by name and parameters
	 * @param clazz
	 * @param name
	 * @param parameterTypes
	 */
	protected ReflectorMethod(final Class<?> clazz, final String name, Class<?>... parameterTypes) {
		try {
			this.method = clazz.getDeclaredMethod(name, parameterTypes);
		} catch (NoSuchMethodException e) {
			throw new ReflectorException("Could not invoke method " + name, e.getCause());
		} catch (SecurityException e) {
			throw new ReflectorException("Could not invoke method " + name, e.getCause());
		}
	}

	public String getName() {
		return this.method.getName();
	}

}

@@ -127,16 +127,66 @@
 ption;%0A%0A
+/**%0A * Class method%0A *  %0A * @author renato%0A *%0A */%0A
 public c
@@ -234,16 +234,125 @@
 ethod;%0A%0A
+%09/**%0A%09 * Create a class from methods by name%0A%09 * @param clazz%0A%09 * @param name%0A%09 * @param parameterTypes%0A%09 */%0A
 %09protect

add comments