-
Notifications
You must be signed in to change notification settings - Fork 28
/
extendableMessages.kts
42 lines (33 loc) · 1.45 KB
/
extendableMessages.kts
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
import com.github.marcoferrer.krotoplus.proto.ProtoMessage
// language=java
fun messageImplements(message: ProtoMessage): String =
"com.github.marcoferrer.krotoplus.message.KpMessage<${message.canonicalJavaName},${message.canonicalJavaName}.Builder>,"
// language=java
fun builderImplements(message: ProtoMessage): String =
"com.github.marcoferrer.krotoplus.message.KpBuilder<${message.canonicalJavaName}>,"
// language=java
fun classScope(message: ProtoMessage) = """
@javax.annotation.Nonnull
public static final Companion Kroto =
com.github.marcoferrer.krotoplus.message.KpCompanion.Registry
.initializeCompanion(${message.canonicalJavaName}.class, new Companion());
@javax.annotation.Nonnull
@Override
public ${message.canonicalJavaName}.Companion getCompanion() {
return ${message.canonicalJavaName}.Kroto;
}
public static final class Companion implements
com.github.marcoferrer.krotoplus.message.KpCompanion<${message.canonicalJavaName},${message.canonicalJavaName}.Builder> {
private Companion(){}
@javax.annotation.Nonnull
@Override
public ${message.canonicalJavaName} getDefaultInstance() {
return ${message.canonicalJavaName}.getDefaultInstance();
}
@javax.annotation.Nonnull
@Override
public ${message.canonicalJavaName}.Builder newBuilder() {
return ${message.canonicalJavaName}.newBuilder();
}
}
"""