/**
* Engine entity. @author MyEclipse Persistence Tools
*/
public class Engine implements java.io.Serializable {
// Fields
private Long engineId;
private String engineName;
private String engineType;
// Constructors
/** default constructor */
public Engine() {
}
/** minimal constructor */
public Engine(Long engineId) {
this.engineId = engineId;
}
public Engine(String engineName, String engineType) {
this.engineName = engineName;
this.engineType = engineType;
}
/** full constructor */
public Engine(Long engineId, String engineName, String engineType) {
this.engineId = engineId;
this.engineName = engineName;
this.engineType = engineType;
}
// Property accessors
public Long getEngineId() {
return this.engineId;
}
public void setEngineId(Long engineId) {
this.engineId = engineId;
}
public String getEngineName() {
return this.engineName;
}
public void setEngineName(String engineName) {
this.engineName = engineName;
}
public String getEngineType() {
return this.engineType;
}
public void setEngineType(String engineType) {
this.engineType = engineType;
}
public static void main(String[] args) throws Exception {
Engine m = new Engine("汽车","发动机");
Class clazz = m.getClass();
Field[] f = clazz.getDeclaredFields();
String[] name = field2Name(f);
Object[] value = field2Value(f, m);
showNameAndValue(name, value);
}
public static void showNameAndValue(String[] name, Object[] value) {
for (int i = 0; i < name.length; i++) {
System.out.println("--" + i + "--");
System.out.println("name:" + name[i]);
System.out.println("Value:" + value[i]);
System.out.println("-- --");
}
}
public static String[] field2Name(Field[] f) {
String[] name = new String[f.length];
for (int i = 0; i < f.length; i++) {
name[i] = f[i].getName();
}
return name;
}
public static Object[] field2Value(Field[] f, Object o) throws Exception {
Object[] value = new Object[f.length];
for (int i = 0; i < f.length; i++) {
value[i] = f[i].get(o);
}
return value;
}
}
public static Object[] field2Value(Field[] fields, Object o) throws Exception {
Object[] values = new Object[fields.length];
Class classType = o.getClass();
for (int i = 0; i < fields.length; i++) {
String fieldName = fields[i].getName();
String firstLetter = fieldName.substring(0, 1).toUpperCase();
String getMethodName = "get" + firstLetter + fieldName.substring(1);
Method getMethod = classType.getMethod(getMethodName, new Class[] {});
values[i] = getMethod.invoke(o, new Object[] {});
}
return values;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有