-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ Utils | |
zip | ||
gson/index | ||
jackson/index | ||
property/index | ||
property/index | ||
protobuf/index |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Protocol Buffers | ||
=============================== | ||
|
||
.. toctree:: | ||
:maxdepth: 3 | ||
:numbered: 0 | ||
|
||
protobufJava | ||
protobufLanguageGuide |
This file contains 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
This file contains 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
This file contains 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
29 changes: 29 additions & 0 deletions
29
utils/src/main/java/t5750/utils/protobuf/ProtobufJavaTest.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package t5750.utils.protobuf; | ||
|
||
import t5750.utils.util.Global; | ||
|
||
public class ProtobufJavaTest { | ||
public static void main(String[] args) { | ||
EmployeeProto.Employee.PhoneType phoneType = EmployeeProto.Employee.PhoneType.MOBILE; | ||
EmployeeProto.Employee.PhoneNumber phoneNumber = EmployeeProto.Employee.PhoneNumber | ||
.newBuilder().setNumber("1234567").setType(phoneType).build(); | ||
EmployeeProto.Employee.AddressType addressType = EmployeeProto.Employee.AddressType.PERMANENT; | ||
EmployeeProto.Employee.Address address = EmployeeProto.Employee.Address | ||
.newBuilder().setStreet("Street").setCity("City").setZip(123456) | ||
.setState("State").setCountry("Country").setType(addressType) | ||
.build(); | ||
EmployeeProto.Employee employee = EmployeeProto.Employee.newBuilder() | ||
.setId(1234).setName(Global.T5750.toUpperCase()) | ||
.setEmail(Global.T5750 + "@email.com").addPhones(phoneNumber) | ||
.addAddress(address).build(); | ||
EmployeeProto.Organization organization = EmployeeProto.Organization | ||
.newBuilder().addEmployee(employee).build(); | ||
for (EmployeeProto.Employee emp : organization.getEmployeeList()) { | ||
System.out.println(emp.getId()); | ||
System.out.println(emp.getName()); | ||
System.out.println(emp.getEmail()); | ||
System.out.println(emp.getPhonesList().get(0)); | ||
System.out.println(emp.getAddressList().get(0)); | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
syntax = "proto3"; | ||
|
||
option java_package = "t5750.utils.protobuf"; | ||
option java_outer_classname = "EmployeeProto"; | ||
|
||
message Employee { | ||
int32 id = 1; | ||
string name = 2; | ||
string email = 3; | ||
|
||
enum PhoneType { | ||
MOBILE = 0; | ||
HOME = 1; | ||
WORK = 2; | ||
} | ||
|
||
message PhoneNumber { | ||
string number = 1; | ||
PhoneType type = 2; | ||
} | ||
|
||
repeated PhoneNumber phones = 4; | ||
|
||
enum AddressType { | ||
PERMANENT = 0; | ||
COMMUNICATION = 1; | ||
} | ||
|
||
message Address { | ||
string street = 1; | ||
string city = 2; | ||
int32 zip = 3; | ||
string state = 4; | ||
string country = 5; | ||
AddressType type = 6; | ||
} | ||
|
||
repeated Address address = 5; | ||
} | ||
|
||
message Organization { | ||
repeated Employee employee = 1; | ||
} |