Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
a10a5272
Commit
a10a5272
authored
Jun 14, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
常规BUG的修改
parent
76059194
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
8 deletions
+75
-8
SetSetpictureVo.java
...e/src/main/java/com/yanzuoguang/util/SetSetpictureVo.java
+54
-0
ObjectHelper.java
...src/main/java/com/yanzuoguang/util/base/ObjectHelper.java
+21
-8
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/SetSetpictureVo.java
0 → 100644
View file @
a10a5272
//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));
// }
//}
yzg-util-base/src/main/java/com/yanzuoguang/util/base/ObjectHelper.java
View file @
a10a5272
...
...
@@ -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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment