Commit a10a5272 authored by yanzg's avatar yanzg

常规BUG的修改

parent 76059194
//package com.yanzuoguang.util;
//
//import com.yanzuoguang.util.base.MethodField;
//import com.yanzuoguang.util.base.ObjectHelper;
//import com.yanzuoguang.util.helper.JsonHelper;
//import com.yanzuoguang.util.helper.StringHelper;
//import com.yanzuoguang.util.vo.BaseVo;
//import com.yanzuoguang.util.vo.InitDao;
//
//import java.util.HashMap;
//
///**
// * 座次图关联表
// *
// * @author 朱磊
// */
//public class SetSetpictureVo extends BaseVo implements InitDao {
//
// /**
// * 座次图关联ID
// */
// private String setPictureId;
// /**
// * 座次图ID
// */
// private String pictureId;
//
// @Override
// public void init() {
// this.setPictureId = StringHelper.getFirst(this.setPictureId, StringHelper.EMPTY);
// this.pictureId = StringHelper.getFirst(this.pictureId, StringHelper.EMPTY);
// }
//
// public String getSetPictureId() {
// return setPictureId;
// }
//
// public void setSetPictureId(String setPictureId) {
// this.setPictureId = setPictureId;
// }
//
// public String getPictureId() {
// return pictureId;
// }
//
// public void setPictureId(String pictureId) {
// this.pictureId = pictureId;
// }
//
// public static void main(String[] args) {
// HashMap<String, MethodField> initTypeField = ObjectHelper.getTypeField(SetSetpictureVo.class);
// System.out.println(JsonHelper.serialize(initTypeField));
// }
//}
......@@ -248,10 +248,10 @@ public class ObjectHelper {
* 获取缓存中的字段
* @param typeCache 类型
* @param fromName 来源名称
* @param toName 目标名称
* @return
*/
private static MethodField getField(HashMap<String, MethodField> typeCache, String fromName) {
String toName = getSimpleName(fromName);
private static MethodField getField(HashMap<String, MethodField> typeCache, String fromName, String toName) {
if (!typeCache.containsKey(toName)) {
MethodField newObj = new MethodField();
typeCache.put(toName, newObj);
......@@ -268,7 +268,7 @@ public class ObjectHelper {
* @return
*/
private static String getSimpleName(String fromName) {
String toName = fromName.toLowerCase().replace("_", "");
String toName = getSimpleFieldName(fromName);
if (toName.startsWith(METHOD_IS)) {
toName = toName.substring(METHOD_IS.length());
} else if (toName.startsWith(METHOD_GET)) {
......@@ -278,7 +278,18 @@ public class ObjectHelper {
} else {
return toName;
}
return getSimpleName(toName);
return toName;
}
/**
* 获取字段处理名称
*
* @param fromName 字段名称
* @return 属性名称
*/
private static String getSimpleFieldName(String fromName) {
String toName = fromName.toLowerCase().replace("_", "");
return toName;
}
/**
......@@ -304,10 +315,11 @@ public class ObjectHelper {
// 忽略大小写、忽略下划线 _
for (Field field : fields) {
MethodField obj = getField(typeCache, field.getName());
if (Modifier.isStatic(field.getModifiers())) {
continue;
}
String toName = getSimpleFieldName(field.getName());
MethodField obj = getField(typeCache, field.getName(), toName);
if (obj.getField() == null) {
obj.setField(field);
}
......@@ -318,13 +330,14 @@ public class ObjectHelper {
}
String methodNameSource = method.getName();
String methodNameSimple = methodNameSource.toLowerCase();
String toName = getSimpleName(methodNameSource);
if ("getClass".equals(methodNameSource)) {
continue;
} else if (methodNameSimple.startsWith("set")) {
if (method.getParameterTypes().length != 1) {
continue;
}
MethodField obj = getField(typeCache, methodNameSource);
MethodField obj = getField(typeCache, methodNameSource,toName);
if (obj.getSetMethod() == null) {
obj.setSetMethod(method);
}
......@@ -332,7 +345,7 @@ public class ObjectHelper {
if (method.getReturnType() == null) {
continue;
}
MethodField obj = getField(typeCache, methodNameSource);
MethodField obj = getField(typeCache, methodNameSource,toName);
if (obj.getGetMethod() == null) {
obj.setGetMethod(method);
}
......@@ -340,7 +353,7 @@ public class ObjectHelper {
if (method.getReturnType() == null) {
continue;
}
MethodField obj = getField(typeCache, methodNameSource);
MethodField obj = getField(typeCache, methodNameSource,toName);
if (obj.getGetMethod() == null) {
obj.setGetMethod(method);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment