package CoreFS.SA01;

import java.lang.reflect.Field;

public class CoreIvokeUtil {
	
	public static String[] getFiledNames(Class c) {
		Field[] f = c.getDeclaredFields();
		String[] fnames = new String[f.length];
		for(int i = 0;i<fnames.length;i++) {
			fnames[i] = f[i].getName();
		}
		return fnames;
	}

	public String[] getMethodNames(Class c, String gsflag) {
		Field[] f = c.getDeclaredFields();
		String[] mtdnames = new String[f.length];
		for (int i = 0; i < f.length; i++) {
			if ("g".equals(gsflag)) {
				mtdnames[i] = "get"
						+ f[i].getName().substring(0, 1).toUpperCase()
						+ f[i].getName().substring(1);
			} else if ("s".equals(gsflag)) {
				mtdnames[i] = "set"
						+ f[i].getName().substring(0, 1).toUpperCase()
						+ f[i].getName().substring(1);
			}
		}

		return mtdnames;
	}

	public String[] getSetMethodNames(Class c) {

		return this.getMethodNames(c, "s");
	}

	public String[] getGetMethodNames(Class c) {
		return this.getMethodNames(c, "g");
	}

}
