(Map src, Type typeOfSrc, JsonSerializationContext context)
| 34 | final class MapTypeAdapter extends BaseMapTypeAdapter { |
| 35 | |
| 36 | public JsonElement serialize(Map src, Type typeOfSrc, JsonSerializationContext context) { |
| 37 | JsonObject map = new JsonObject(); |
| 38 | Type childGenericType = null; |
| 39 | if (typeOfSrc instanceof ParameterizedType) { |
| 40 | Class<?> rawTypeOfSrc = $Gson$Types.getRawType(typeOfSrc); |
| 41 | childGenericType = $Gson$Types.getMapKeyAndValueTypes(typeOfSrc, rawTypeOfSrc)[1]; |
| 42 | } |
| 43 | |
| 44 | for (Map.Entry entry : (Set<Map.Entry>) src.entrySet()) { |
| 45 | Object value = entry.getValue(); |
| 46 | |
| 47 | JsonElement valueElement; |
| 48 | if (value == null) { |
| 49 | valueElement = JsonNull.createJsonNull(); |
| 50 | } else { |
| 51 | Type childType = (childGenericType == null) |
| 52 | ? value.getClass() : childGenericType; |
| 53 | valueElement = serialize(context, value, childType); |
| 54 | } |
| 55 | map.add(String.valueOf(entry.getKey()), valueElement); |
| 56 | } |
| 57 | return map; |
| 58 | } |
| 59 | |
| 60 | public Map deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) |
| 61 | throws JsonParseException { |
nothing calls this directly
no test coverage detected