FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java/src/main/java/com/jsoniter/ReflectionEnumDecoder.java at master · baowchen/java · GitHub
baowchen
/
java
Public
forked from
json-iterator/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
java
/
src
/
main
/
java
/
com
/
jsoniter
/
ReflectionEnumDecoder.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (28 loc) · 912 Bytes
Breadcrumbs
java
/
src
/
main
/
java
/
com
/
jsoniter
/
ReflectionEnumDecoder.java
Copy path
File metadata and controls
33 lines (28 loc) · 912 Bytes
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
package
com
.
jsoniter
;
import
com
.
jsoniter
.
spi
.
Decoder
;
import
com
.
jsoniter
.
spi
.
Slice
;
import
java
.
io
.
IOException
;
import
java
.
util
.
HashMap
;
import
java
.
util
.
Map
;
class
ReflectionEnumDecoder
implements
Decoder
{
private
final
Map
<
Slice
,
Object
>
enumMap
=
new
HashMap
<
Slice
,
Object
>();
private
Class
clazz
;
public
ReflectionEnumDecoder
(
Class
clazz
) {
this
.
clazz
=
clazz
;
for
(
Object
e
:
clazz
.
getEnumConstants
()) {
enumMap
.
put
(
Slice
.
make
(
e
.
toString
()),
e
);
}
}
@
Override
public
Object
decode
(
JsonIterator
iter
)
throws
IOException
{
if
(
iter
.
readNull
()) {
return
null
;
}
Slice
slice
=
IterImpl
.
readSlice
(
iter
);
Object
e
=
enumMap
.
get
(
slice
);
if
(
e
==
null
) {
throw
iter
.
reportError
(
"ReflectionEnumDecoder"
,
slice
+
" is not valid enum for "
+
clazz
);
}
return
e
;
}
}
Back
|
FazBrowse Home
|
New Git URL