Reference Guide

Table Of Contents
repeated PhoneNumber phone = 4;
}
message AddressBook {
repeated Person person = 1;
}
The protocol file above would be run through GPB’s Java compiler (See “.proto Compilation
Process Below) to generate the data access classes to represent these messages. Message
builders would allow new instances of the message to be created for distribution by the
Coordination Services. Normal set/get accessor methods will also be provided for each field.
Below are examples of creating a new instance of the message in Java. Reading the record out
will return this GPB generated object for the application to interact with as usual.
public class AddPerson {
// This function creates a simple instance of a GPB Person object
// that can then be written to one of the Coordination Services.
public static Person createTestPerson(){
// Initial GPB instance builder.
Person.Builder person = Person.newBuilder();
// Set REQUIRED Person fields.
person.setName(“John Doe”);
person.setId("1234”);
// Set OPTIONAL Peson fields.
person.setEmail(“john.doe@gmail.com”);
// Set REQUIRED Phone fields.
Person.PhoneNumber.Builder phoneNumber =
Person.PhoneNumber.newBuilder().setNumber(“555-555-5555”);
// Set OPTIONAL Phone fields.
phoneNumber.setType(Person.PhoneType.MOBILE);
person.addPhone(phoneNumber);
}
return person.build();
}
Versioning Rules
77