package com.example; import java.lang.reflect.Field; /** * General document master table * * @author yi.zhe * @time 2014-9-10 6:44:17 PM */ public class BillMaster extends BaseTableBean { public String CompanyID = "123"; Integer id; Long BillNo; public static void main(String[] args) throws Exception { BillMaster a = new BillMaster (); a.iniContentValues (); } public BillMaster () { } public void iniContentValues() { Field[] fields = getClass().getDeclaredFields(); for (int i = 0; i < fields.length; i++) { Field f = fields[i]; f.setAccessible(true); try { if (f.getType().equals(java.lang.Integer.class)) { if (f.get(this) == null) { System.out.println(f.getName() + ":" + 0); } else { System.out.println(f.getName() + ":" + (int) f.get(this)); } } if (f.getType().equals(java.lang.Long.class)) { if (null == f.get(this)) { System.out.println(f.getName() + ":" + 0); } else { System.out.println(f.getName() + ":" + (long) f.get(this)); } } if (f.getType().equals(java.lang.String.class)) { System.out.println(f.getName() + ":" + (String) f.get(this)); } } catch (IllegalAccessException e) { e.printStackTrace (); } } } }
Get the attribute name attribute value attribute type of javaBean
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326781089&siteId=291194637
Ranking