Package org.eclipse.mosaic.lib.util.gson
Class DataFieldAdapter
java.lang.Object
com.google.gson.TypeAdapter<Long>
org.eclipse.mosaic.lib.util.gson.DataFieldAdapter
Adapter for JSON fields which translates values as string representatives to
actual long values representing the number of bits, e.g.
for size: "10 Bytes" -> 80, "2kbit" -> 2000
for bandwidth: "10 MBps km/h" -> 80000000, "5 kbps" -> 5000
Note: using "b" or "B" is a difference, as former stands for bits and later for bytes.
Usage:
for size: "10 Bytes" -> 80, "2kbit" -> 2000
for bandwidth: "10 MBps km/h" -> 80000000, "5 kbps" -> 5000
Note: using "b" or "B" is a difference, as former stands for bits and later for bytes.
Usage:
@JsonAdapter(DataFieldAdapter.Size.class) public long size;
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static class
static class
-
Field Summary
Fields -
Method Summary
Methods inherited from class com.google.gson.TypeAdapter
fromJson, fromJson, fromJsonTree, nullSafe, toJson, toJson, toJsonTree
-
Field Details
-
PS
- See Also:
-
-
Method Details
-
write
- Specified by:
write
in classcom.google.gson.TypeAdapter<Long>
- Throws:
IOException
-
read
- Specified by:
read
in classcom.google.gson.TypeAdapter<Long>
- Throws:
IOException
-