demo-protobuf/src/main/java/com/github/shoothzj/demo/protobuf/addressbook/ListPeople.java
static void print(AddressBookProtos.AddressBook addressBook) {
        for (AddressBookProtos.Person person : addressBook.getPeopleList()) {
            System.out.println("Person ID: " + person.getId());
            System.out.println("  Name: " + person.getName());
            if (person.hasEmail()) {
                System.out.println("  E-mail address: " + person.getEmail());
            }

            for (AddressBookProtos.Person.PhoneNumber phoneNumber : person.getPhonesList()) {
                switch (phoneNumber.getType()) {
                    case MOBILE:
                        System.out.print("  Mobile phone #: ");
                        break;
                    case HOME:
                        System.out.print("  Home phone #: ");
                        break;
                    case WORK:
                        System.out.print("  Work phone #: ");
                        break;
                }
                System.out.println(phoneNumber.getNumber());
            }
        }
    }
// Iterates though all people in the AddressBook and prints info about them.
Iterates though all people in the AddressBook and prints info about them.
Iterates though all people in the AddressBook and prints info about them .
static void print(AddressBookProtos.AddressBook addressBook) {
        for (AddressBookProtos.Person person : addressBook.getPeopleList()) {
            System.out.println("Person ID: " + person.getId());
            System.out.println("  Name: " + person.getName());
            if (person.hasEmail()) {
                System.out.println("  E-mail address: " + person.getEmail());
            }
            for (AddressBookProtos.Person.PhoneNumber phoneNumber : person.getPhonesList()) {
                switch (phoneNumber.getType()) {
                    case MOBILE:
                        System.out.print("  Mobile phone #: ");
                        break;
                    case HOME:
                        System.out.print("  Home phone #: ");
                        break;
                    case WORK:
                        System.out.print("  Work phone #: ");
                        break;
                }
                System.out.println(phoneNumber.getNumber());
            }
        }
    }
static void print ( AddressBookProtos . AddressBook addressBook ) { for ( AddressBookProtos . Person person : addressBook . getPeopleList ( ) ) { System . out . println ( "Person ID: " + person . getId ( ) ) ; System . out . println ( "  Name: " + person . getName ( ) ) ; if ( person . hasEmail ( ) ) { System . out . println ( "  E-mail address: " + person . getEmail ( ) ) ; } for ( AddressBookProtos . Person . PhoneNumber phoneNumber : person . getPhonesList ( ) ) { switch ( phoneNumber . getType ( ) ) { case MOBILE : System . out . print ( "  Mobile phone #: " ) ; break ; case HOME : System . out . print ( "  Home phone #: " ) ; break ; case WORK : System . out . print ( "  Work phone #: " ) ; break ; } System . out . println ( phoneNumber . getNumber ( ) ) ; } } }
Iterates though all people in the AddressBook and prints info about them.
Iterates though all people in the AddressBook and prints info about them .