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
f6316c38
Commit
f6316c38
authored
Jul 20, 2022
by
xianjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改工具类
parent
d1686dde
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
3 deletions
+37
-3
ObjectHelper.java
...src/main/java/com/yanzuoguang/util/base/ObjectHelper.java
+37
-3
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/base/ObjectHelper.java
View file @
f6316c38
...
...
@@ -306,13 +306,24 @@ public class ObjectHelper {
return
toName
;
}
/**
* 获取字段处理名称
*
* @param fromName 字段名称
* @return 属性名称
*/
private
static
String
getObjectFieldName
(
String
fromName
)
{
String
toName
=
fromName
.
replace
(
"_"
,
""
);
return
toName
;
}
/**
* 获取实体的字段
*
* @param cls 需要获取的类型
* @return 获取字段之间的对应关系
*/
private
static
HashMap
<
String
,
MethodField
>
getInitTypeField
(
Class
<?>
cls
)
{
private
static
HashMap
<
String
,
MethodField
>
getInitTypeField
(
Class
<?>
cls
,
boolean
isTableField
)
{
HashMap
<
String
,
MethodField
>
typeCache
=
new
LinkedHashMap
<
String
,
MethodField
>();
List
<
Field
>
fields
=
new
ArrayList
<
Field
>();
...
...
@@ -332,7 +343,13 @@ public class ObjectHelper {
if
(
Modifier
.
isStatic
(
field
.
getModifiers
()))
{
continue
;
}
String
toName
=
getSimpleFieldName
(
field
.
getName
());
String
toName
;
if
(
isTableField
)
{
toName
=
getSimpleFieldName
(
field
.
getName
());
}
else
{
toName
=
getObjectFieldName
(
field
.
getName
());
}
MethodField
obj
=
getField
(
typeCache
,
field
.
getName
(),
toName
);
if
(
obj
.
getField
()
==
null
)
{
obj
.
setField
(
field
);
...
...
@@ -382,7 +399,24 @@ public class ObjectHelper {
if
(
MAP_CACHE
.
containsKey
(
type
))
{
typeCache
=
MAP_CACHE
.
get
(
type
);
}
else
{
typeCache
=
getInitTypeField
(
type
);
typeCache
=
getInitTypeField
(
type
,
true
);
MAP_CACHE
.
put
(
type
,
typeCache
);
}
return
typeCache
;
}
/**
* 获取一个表中的字段
*
* @param type
* @return
*/
public
static
HashMap
<
String
,
MethodField
>
getObjectTypeField
(
Class
<?>
type
)
{
HashMap
<
String
,
MethodField
>
typeCache
;
if
(
MAP_CACHE
.
containsKey
(
type
))
{
typeCache
=
MAP_CACHE
.
get
(
type
);
}
else
{
typeCache
=
getInitTypeField
(
type
,
false
);
MAP_CACHE
.
put
(
type
,
typeCache
);
}
return
typeCache
;
...
...
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