Last active
August 8, 2017 21:57
-
-
Save hnaoto/6d031dea6d3996b9a48a0b324cd91b7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For Java, the compiler generates a .java file with a class for each message type, | |
//as well as a special Builder classes for creating message class instances. | |
syntax = "proto2"; | |
//package declarations, helps to prevent naming conflicts between diffrent projects | |
package tutorial; | |
//in what java package name your generated class should live | |
option java_package = "com.example.tutorial"; | |
//define the class name which should contain all of the classes in this file | |
option java_outer_classname = "AddressBookProtos"; | |
message Person { | |
// " = 1", " = 2" markers on each element identify the unique "tag" that field uses in the binary encoding. | |
//Tag numbers 1-15 require one less byte to encode than higher numbers, | |
//Forimization you can decide to use those tags for the commonly used or repeated elements, | |
//leaving tags 16 and higher for less-commonly used optional elements. | |
//Each element in a repeated field requires re-encoding the tag number, | |
//so repeated fields are particularly good candidates for this optimization. | |
required string name = 1; | |
required int32 id = 2; | |
optional string email = 3; | |
enum PhoneType { | |
MOBILE = 0; | |
HOME = 1; | |
WORK = 2; | |
} | |
message PhoneNumber { | |
required string number = 1; | |
optional PhoneType type = 2 [default = HOME]; | |
} | |
repeated PhoneNumber phones = 4; | |
} | |
message AddressBook { | |
repeated Person people = 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment