Skip to content

Commit b4313f2

Browse files
committed
revert to anon class to revert Java source
1 parent e703748 commit b4313f2

File tree

2 files changed

+98
-16
lines changed

2 files changed

+98
-16
lines changed

src/AndroidClient/android/src/main/java/net/servicestack/client/JsonSerializers.java

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,80 @@
1010
import com.google.gson.stream.JsonWriter;
1111

1212
import java.io.IOException;
13+
import java.lang.reflect.Type;
1314
import java.util.*;
1415

1516
public class JsonSerializers {
1617
public static JsonSerializer<Date> getDateSerializer(){
17-
return (src, typeOfSrc, context) -> src == null ? null : new JsonPrimitive(Utils.toJsonDate(src));
18+
return new JsonSerializer<Date>() {
19+
@Override
20+
public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
21+
return src == null ? null : new JsonPrimitive(Utils.toJsonDate(src));
22+
}
23+
};
1824
}
1925

2026
public static JsonDeserializer<Date> getDateDeserializer(){
21-
return (json, typeOfT, context) -> json == null ? null : Utils.parseDate(json.getAsString());
27+
return new JsonDeserializer<Date>() {
28+
@Override
29+
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
30+
return json == null ? null : Utils.parseDate(json.getAsString());
31+
}
32+
};
2233
}
2334

2435
public static JsonSerializer<TimeSpan> getTimeSpanSerializer(){
25-
return (src, typeOfSrc, context) -> src == null ? null : new JsonPrimitive(src.toXsdDuration());
36+
return new JsonSerializer<TimeSpan>() {
37+
@Override
38+
public JsonElement serialize(TimeSpan src, Type typeOfSrc, JsonSerializationContext context) {
39+
return src == null ? null : new JsonPrimitive(src.toXsdDuration());
40+
}
41+
};
2642
}
2743

2844
public static JsonDeserializer<TimeSpan> getTimeSpanDeserializer(){
29-
return (json, typeOfT, context) -> json == null ? null : TimeSpan.parse(json.getAsString());
45+
return new JsonDeserializer<TimeSpan>() {
46+
@Override
47+
public TimeSpan deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
48+
return json == null ? null : TimeSpan.parse(json.getAsString());
49+
}
50+
};
3051
}
3152

3253
public static JsonSerializer<UUID> getGuidSerializer(){
33-
return (src, typeOfSrc, context) -> src == null ? null : new JsonPrimitive(Utils.toGuidString(src));
54+
return new JsonSerializer<UUID>() {
55+
@Override
56+
public JsonElement serialize(UUID src, Type typeOfSrc, JsonSerializationContext context) {
57+
return src == null ? null : new JsonPrimitive(Utils.toGuidString(src));
58+
}
59+
};
3460
}
3561

3662
public static JsonDeserializer<UUID> getGuidDeserializer(){
37-
return (json, typeOfT, context) -> json == null ? null : Utils.fromGuidString(json.getAsString());
63+
return new JsonDeserializer<UUID>() {
64+
@Override
65+
public UUID deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
66+
return json == null ? null : Utils.fromGuidString(json.getAsString());
67+
}
68+
};
3869
}
3970

4071
public static JsonSerializer<byte[]> getByteArraySerializer(){
41-
return (src, typeOfSrc, context) -> src == null ? null : new JsonPrimitive(Base64.getEncoder().encodeToString(src));
72+
return new JsonSerializer<byte[]>() {
73+
@Override
74+
public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContext context) {
75+
return src == null ? null : new JsonPrimitive(Base64.getEncoder().encodeToString(src));
76+
}
77+
};
4278
}
4379

4480
public static JsonDeserializer<byte[]> getByteArrayDeserializer(){
45-
return (json, typeOfT, context) -> json == null ? null : Base64.getDecoder().decode(json.getAsString());
81+
return new JsonDeserializer<byte[]>() {
82+
@Override
83+
public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
84+
return json == null ? null : Base64.getDecoder().decode(json.getAsString());
85+
}
86+
};
4687
}
4788

4889
public static class CaseInsensitiveEnumTypeAdapterFactory implements TypeAdapterFactory {

src/AndroidClient/client/src/main/java/net/servicestack/client/JsonSerializers.java

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,80 @@
1010
import com.google.gson.stream.JsonWriter;
1111

1212
import java.io.IOException;
13+
import java.lang.reflect.Type;
1314
import java.util.*;
1415

1516
public class JsonSerializers {
1617
public static JsonSerializer<Date> getDateSerializer(){
17-
return (src, typeOfSrc, context) -> src == null ? null : new JsonPrimitive(Utils.toJsonDate(src));
18+
return new JsonSerializer<Date>() {
19+
@Override
20+
public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
21+
return src == null ? null : new JsonPrimitive(Utils.toJsonDate(src));
22+
}
23+
};
1824
}
1925

2026
public static JsonDeserializer<Date> getDateDeserializer(){
21-
return (json, typeOfT, context) -> json == null ? null : Utils.parseDate(json.getAsString());
27+
return new JsonDeserializer<Date>() {
28+
@Override
29+
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
30+
return json == null ? null : Utils.parseDate(json.getAsString());
31+
}
32+
};
2233
}
2334

2435
public static JsonSerializer<TimeSpan> getTimeSpanSerializer(){
25-
return (src, typeOfSrc, context) -> src == null ? null : new JsonPrimitive(src.toXsdDuration());
36+
return new JsonSerializer<TimeSpan>() {
37+
@Override
38+
public JsonElement serialize(TimeSpan src, Type typeOfSrc, JsonSerializationContext context) {
39+
return src == null ? null : new JsonPrimitive(src.toXsdDuration());
40+
}
41+
};
2642
}
2743

2844
public static JsonDeserializer<TimeSpan> getTimeSpanDeserializer(){
29-
return (json, typeOfT, context) -> json == null ? null : TimeSpan.parse(json.getAsString());
45+
return new JsonDeserializer<TimeSpan>() {
46+
@Override
47+
public TimeSpan deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
48+
return json == null ? null : TimeSpan.parse(json.getAsString());
49+
}
50+
};
3051
}
3152

3253
public static JsonSerializer<UUID> getGuidSerializer(){
33-
return (src, typeOfSrc, context) -> src == null ? null : new JsonPrimitive(Utils.toGuidString(src));
54+
return new JsonSerializer<UUID>() {
55+
@Override
56+
public JsonElement serialize(UUID src, Type typeOfSrc, JsonSerializationContext context) {
57+
return src == null ? null : new JsonPrimitive(Utils.toGuidString(src));
58+
}
59+
};
3460
}
3561

3662
public static JsonDeserializer<UUID> getGuidDeserializer(){
37-
return (json, typeOfT, context) -> json == null ? null : Utils.fromGuidString(json.getAsString());
63+
return new JsonDeserializer<UUID>() {
64+
@Override
65+
public UUID deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
66+
return json == null ? null : Utils.fromGuidString(json.getAsString());
67+
}
68+
};
3869
}
3970

4071
public static JsonSerializer<byte[]> getByteArraySerializer(){
41-
return (src, typeOfSrc, context) -> src == null ? null : new JsonPrimitive(Base64.getEncoder().encodeToString(src));
72+
return new JsonSerializer<byte[]>() {
73+
@Override
74+
public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContext context) {
75+
return src == null ? null : new JsonPrimitive(Base64.getEncoder().encodeToString(src));
76+
}
77+
};
4278
}
4379

4480
public static JsonDeserializer<byte[]> getByteArrayDeserializer(){
45-
return (json, typeOfT, context) -> json == null ? null : Base64.getDecoder().decode(json.getAsString());
81+
return new JsonDeserializer<byte[]>() {
82+
@Override
83+
public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
84+
return json == null ? null : Base64.getDecoder().decode(json.getAsString());
85+
}
86+
};
4687
}
4788

4889
public static class CaseInsensitiveEnumTypeAdapterFactory implements TypeAdapterFactory {

0 commit comments

Comments
 (0)