📄 formmanager.java
字号:
/*
* Created on 2007-7-18
* Last modified on 2007-7-18
* Powered by YeQiangWei.com
*/
package com.yeqiangwei.club.controller.form.build;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class FormManager {
public static<T> T building(T t) throws InstantiationException, IllegalAccessException, IllegalArgumentException, SecurityException, InvocationTargetException, NoSuchMethodException{
Method[] m = t.getClass().getDeclaredMethods();
Field[] f = t.getClass().getDeclaredFields();
for(int i=0; i<f.length; i++){
//System.out.println(f[i].getName());
System.out.println(f[i].getType());
//Integer iii = new Integer("1");
if(f[i].getType().toString().equals("class java.lang.Integer")){
Object o = f[i].getType().getConstructor().toString();
//.newInstance(new Object[]{"1"});
System.out.println(o.getClass()+" "+o);
}
//System.out.println("=================");
System.out.println("=================");
}
System.out.println("++++++++++++++++++++++++");
for(int i=0; i<m.length; i++){
System.out.println(m[i].invoke(t,"1"));
System.out.println("");
System.out.println("=================");
}
return null;
}
/*
public static void test() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException, InstantiationException{
TestForm t = new TestForm();
Method[] m = t.getClass().getDeclaredMethods();
Field[] f = t.getClass().getDeclaredFields();
Field f1 = f[0];
Class[] classzz= {String.class};
Object[] objs = {"1"};
Object p = f1.getType().getConstructors()[0].newInstance(objs);
for(int i=0; i<m.length; i++){
if(("set"+f1.getName()).equalsIgnoreCase(m[i].getName())){
m[i].invoke(t,p);
}
}
System.out.println(t.getI());
//form.getClass().getDeclaredMethods();
}
*/
public static class TestForm{
private Integer i;
public int getI() {
return i;
}
public void setI(int i) {
this.i = i;
}
}
public static void main(String args[]) throws InstantiationException, IllegalAccessException, IllegalArgumentException, SecurityException, InvocationTargetException, NoSuchMethodException{
//FormManager.<RegisterForm>building(new RegisterForm());
//test();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -