FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java/src/main/java/com/jsoniter/CodegenImplMap.java at master · spidasoftware/java · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
spidasoftware
/
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
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
java
/
src
/
main
/
java
/
com
/
jsoniter
/
CodegenImplMap.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (34 loc) · 1.56 KB
Breadcrumbs
java
/
src
/
main
/
java
/
com
/
jsoniter
/
CodegenImplMap.java
Copy path
File metadata and controls
39 lines (34 loc) · 1.56 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
37
38
39
package
com
.
jsoniter
;
import
com
.
jsoniter
.
spi
.
ClassInfo
;
import
com
.
jsoniter
.
spi
.
TypeLiteral
;
import
java
.
lang
.
reflect
.
Type
;
class
CodegenImplMap
{
public
static
String
genMap
(
ClassInfo
classInfo
) {
Type
keyType
=
classInfo
.
typeArgs
[
0
];
Type
valueType
=
classInfo
.
typeArgs
[
1
];
StringBuilder
lines
=
new
StringBuilder
();
append
(
lines
,
"{{clazz}} map = ({{clazz}})com.jsoniter.CodegenAccess.resetExistingObject(iter);"
);
append
(
lines
,
"if (iter.readNull()) { return null; }"
);
append
(
lines
,
"if (map == null) { map = new {{clazz}}(); }"
);
append
(
lines
,
"if (!com.jsoniter.CodegenAccess.readObjectStart(iter)) {"
);
append
(
lines
,
"return map;"
);
append
(
lines
,
"}"
);
append
(
lines
,
"do {"
);
if
(
keyType
==
String
.
class
) {
append
(
lines
,
"Object mapKey = com.jsoniter.CodegenAccess.readObjectFieldAsString(iter);"
);
}
else
{
append
(
lines
,
"Object mapKey = com.jsoniter.CodegenAccess.readMapKey(
\"
"
+
TypeLiteral
.
create
(
keyType
).
getDecoderCacheKey
() +
"
\"
, iter);"
);
}
append
(
lines
,
"map.put(mapKey, {{op}});"
);
append
(
lines
,
"} while (com.jsoniter.CodegenAccess.nextToken(iter) == ',');"
);
append
(
lines
,
"return map;"
);
return
lines
.
toString
()
.
replace
(
"{{clazz}}"
,
classInfo
.
clazz
.
getName
())
.
replace
(
"{{op}}"
,
CodegenImplNative
.
genReadOp
(
valueType
));
}
private
static
void
append
(
StringBuilder
lines
,
String
str
) {
lines
.
append
(
str
);
lines
.
append
(
"
\n
"
);
}
}
Back
|
FazBrowse Home
|
New Git URL