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

import java.util.ArrayList;
import java.util.List;

import br.com.reflector.api.util.ReflectorUtil;

/**
 * 
 * @author Renato Martins
 *
 */
public class ReflectorClass {

	private Class<?> clazz;
	private List<ReflectorMethod> methods;

	public ReflectorClass(Class<?> clazz) {
		this.clazz = clazz;
		this.methods = new ArrayList<ReflectorMethod>();
	}

	public ReflectorMethod method(String name) {
		return new ReflectorMethod(clazz, name);
	}

	public List<ReflectorMethod> methods() {
		this.addMethods(clazz);
		return getMethods();
	}

	public List<ReflectorMethod> methodsAll() {
		this.addMethodsAll(clazz);
		return getMethods();
	}

	private void addMethods(Class<?> clazzParam) {

		for (java.lang.reflect.Method m : clazzParam.getDeclaredMethods()) {
			addMethod(new ReflectorMethod(m.getDeclaringClass(), m.getName()));
		}

	}

	private void addMethodsAll(Class<?> clazzParam) {

		if (ReflectorUtil.isContainsSuperclass(clazzParam)) {
			this.addMethods(clazzParam.getSuperclass());
		}

		this.addMethods(clazzParam);
	}

	private void addMethod(ReflectorMethod m) {
		this.getMethods().add(m);

	}

	private List<ReflectorMethod> getMethods() {
		return this.methods;
	}

}

@@ -143,12 +143,8 @@
 /**%0A
- * %0A
  * @
@@ -165,16 +165,20 @@
 Martins%0A
+ * %0A
  *%0A */%0Ap
@@ -480,24 +480,95 @@
  name);%0A%09%7D%0A%0A
+%09/**%0A%09 * Get methods from class%0A%09 * @return List%3CReflectorMethod%3E%0A%09 */%0A
 %09public List
@@ -642,32 +642,133 @@
 tMethods();%0A%09%7D%0A%0A
+%09/**%0A%09 * Get methods form class and superclass, except Object%0A%09 * @return List%3CReflectorMethod%3E%0A%09 */%0A
 %09public List%3CRef

Add comments