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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
package org.jetbrains.protocolReader;
import org.jetbrains.annotations.Nullable;
/**
* A parser that accepts value of JSON field and outputs value in another form (e.g. string
* is converted to enum constant) to serve field getters in JsonType interfaces.
*/
abstract class ValueReader {
private final boolean nullable;
protected ValueReader(boolean nullable) {
this.nullable = nullable;
}
public ObjectValueReader asJsonTypeParser() {
return null;
}
abstract void appendFinishedValueTypeName(TextOutput out);
void appendInternalValueTypeName(FileScope scope, TextOutput out) {
appendFinishedValueTypeName(out);
}
abstract void writeReadCode(ClassScope methodScope, boolean subtyping, String fieldName, TextOutput out);
public boolean isNullable() {
return nullable;
}
abstract void writeArrayReadCode(ClassScope scope, boolean subtyping, boolean nullable, String fieldName, TextOutput out);
protected void beginReadCall(String readPostfix, boolean subtyping, TextOutput out, @Nullable String fieldName) {
out.append("read");
if (isNullable()) {
out.append("Nullable");
}
out.append(readPostfix).append('(');
addReaderParameter(subtyping, out);
if (!isNullable()) {
out.comma();
if (subtyping) {
out.append("null");
}
else if (fieldName == null) {
out.append("name");
}
else {
out.quote(fieldName);
}
}
}
protected static void addReaderParameter(boolean subtyping, TextOutput out) {
out.append(subtyping ? Util.PENDING_INPUT_READER_NAME : Util.READER_NAME);
}
public boolean isThrowsIOException() {
return false;
}
}
|