blob: 280225bd7a0cc4bf7044bdaa0c4a5aff0f658a30 (
plain)
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
40
41
42
43
44
45
46
|
package org.javacs.lsp;
import java.io.IOException;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.stream.JsonWriter;
import com.google.gson.TypeAdapter;
@JsonAdapter(MarkedString.Adapter.class)
public class MarkedString {
public String language, value;
public MarkedString() {}
public MarkedString(String value) {
this.value = value;
}
public MarkedString(String language, String value) {
this.language = language;
this.value = value;
}
public static class Adapter extends TypeAdapter<MarkedString> {
@Override
public void write(JsonWriter out, MarkedString markedString) throws IOException {
if (markedString.language == null) {
out.value(markedString.value);
} else {
out.beginObject();
out.name("language");
out.value(markedString.language);
out.name("value");
out.value(markedString.value);
out.endObject();
}
}
@Override
public MarkedString read(JsonReader reader) throws IOException {
throw new UnsupportedOperationException("Deserializing MarkedString's is unsupported.");
}
}
}
|