FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node-java/src-java/node/CastingUtils.java at master · yudiqing520/node-java · GitHub
yudiqing520
/
node-java
Public
forked from
joeferner/node-java
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
node-java
/
src-java
/
node
/
CastingUtils.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
36 lines (31 loc) · 1.06 KB
Breadcrumbs
node-java
/
src-java
/
node
/
CastingUtils.java
Copy path
File metadata and controls
36 lines (31 loc) · 1.06 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package
node
;
import
java
.
lang
.
reflect
.
Method
;
public
class
CastingUtils
{
public
static
void
cast
(
Method
method
,
Object
[]
args
)
throws
Throwable
{
Class
[]
methodParameterTypes
=
method
.
getParameterTypes
();
if
(
methodParameterTypes
.
length
!=
args
.
length
) {
throw
new
Exception
(
"Method argument length mismatch. Expecting "
+
methodParameterTypes
.
length
+
" found "
+
args
.
length
);
}
for
(
int
i
=
0
;
i
<
methodParameterTypes
.
length
;
i
++) {
args
[
i
] =
cast
(
args
[
i
],
methodParameterTypes
[
i
]);
}
}
public
static
Object
cast
(
Object
o
,
Class
t
) {
if
(
o
==
null
) {
return
null
;
}
Class
oClass
=
o
.
getClass
();
if
(
oClass
==
Integer
.
class
) {
Integer
i
= (
Integer
)
o
;
if
(
t
==
Double
.
class
) {
return
i
.
doubleValue
();
}
}
else
if
(
oClass
==
Double
.
class
) {
Double
d
= (
Double
)
o
;
if
(
t
==
Integer
.
class
) {
return
d
.
intValue
();
}
}
return
o
;
}
}
Back
|
FazBrowse Home
|
New Git URL