I have been studying the google protocol buffer since yesterday and asking a question:
Can I use a custom java class as a field type in a .proto file?
Let me clarify my questions below:
1 - I have the following java class "MyComplexClass.java":
package mypackage;
import another.package1.ClassA;
import another.package2.ClassB;
public class MyComplexClass {
private ClassA var1;
private ClassB var2;
public MyComplexClass(ClassA X, ClassB Y)
this.var1 = X;
this.var2 = Y;
}
2- Now I would like to serialize an instance of the class "MyComplexClass.java". For this purpose, I would like to describe the following message in a .proto file:
message myMessageToBeSerialized {
required ***MyComplexClass*** intanceOfComplexClass = 1;
}
Is it possible to use a custom class MyComplexClass as a field type? Or is it allowed to use only scalar types?
Any help would be greatly appreciated. Thanks in advance.
Horace
source
share