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
76059194
Commit
76059194
authored
Jun 11, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
常规BUG的修改
parent
a106f9bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
14 deletions
+17
-14
StringHelper.java
...c/main/java/com/yanzuoguang/util/helper/StringHelper.java
+17
-14
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/StringHelper.java
View file @
76059194
...
@@ -289,31 +289,34 @@ public class StringHelper {
...
@@ -289,31 +289,34 @@ public class StringHelper {
* @return 返回获取的值
* @return 返回获取的值
*/
*/
public
static
<
T
>
T
to
(
Class
<
T
>
cls
,
Object
from
)
{
public
static
<
T
>
T
to
(
Class
<
T
>
cls
,
Object
from
)
{
if
(
from
==
null
)
{
return
null
;
}
String
vName
=
cls
.
getName
();
String
vName
=
cls
.
getName
();
Object
to
=
null
;
Object
to
=
null
;
if
(
cls
.
isEnum
())
{
if
(
isType
(
cls
,
String
.
class
))
{
String
strValue
=
toString
(
from
);
to
=
EnumHelper
.
toEnum
(
cls
,
strValue
);
}
else
if
(
isType
(
cls
,
String
.
class
))
{
to
=
toString
(
from
);
to
=
toString
(
from
);
}
else
if
(
TYPE_BOOL
.
equals
(
vName
)
||
isType
(
cls
,
Boolean
.
class
))
{
}
else
if
(
TYPE_BOOL
.
equals
(
vName
)
||
(
isType
(
cls
,
Boolean
.
class
)
&&
from
!=
null
))
{
String
strValue
=
toString
(
from
);
String
strValue
=
toString
(
from
);
to
=
toBoolean
(
strValue
);
to
=
toBoolean
(
strValue
);
}
else
if
(
TYPE_INT
.
equals
(
vName
)
||
isType
(
cls
,
Integer
.
class
))
{
}
else
if
(
TYPE_INT
.
equals
(
vName
)
||
(
isType
(
cls
,
Integer
.
class
)
&&
from
!=
null
))
{
to
=
toInt
(
from
);
to
=
toInt
(
from
);
}
else
if
(
TYPE_DOUBLE
.
equals
(
vName
)
||
isType
(
cls
,
Double
.
class
))
{
}
else
if
(
TYPE_DOUBLE
.
equals
(
vName
)
||
(
isType
(
cls
,
Double
.
class
)
&&
from
!=
null
))
{
to
=
toDouble
(
from
);
to
=
toDouble
(
from
);
}
else
if
(
TYPE_FLOAT
.
equals
(
vName
)
||
isType
(
cls
,
Float
.
class
))
{
}
else
if
(
TYPE_FLOAT
.
equals
(
vName
)
||
(
isType
(
cls
,
Float
.
class
)
&&
from
!=
null
))
{
to
=
toDouble
(
from
);
to
=
toDouble
(
from
);
}
else
if
(
isType
(
cls
,
Double
.
class
))
{
to
=
toDecimal
(
from
);
}
else
if
(
isType
(
cls
,
Date
.
class
))
{
}
else
if
(
isType
(
cls
,
Date
.
class
))
{
to
=
DateHelper
.
getDateTime
(
from
);
to
=
DateHelper
.
getDateTime
(
from
);
}
else
if
(
cls
.
isEnum
())
{
String
strValue
=
toString
(
from
);
if
(
strValue
!=
null
)
{
to
=
EnumHelper
.
toEnum
(
cls
,
strValue
);
}
}
}
if
(
to
!=
null
)
{
if
(
to
==
null
&&
from
==
null
)
{
return
null
;
}
else
if
(
to
!=
null
)
{
return
(
T
)
to
;
return
(
T
)
to
;
}
else
{
}
else
{
if
(
ObjectHelper
.
isSub
(
cls
,
from
.
getClass
()))
{
if
(
ObjectHelper
.
isSub
(
cls
,
from
.
getClass
()))
{
...
...
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