@@ -15,8 +15,8 @@ proto3 generated code are highlighted—note that these differences are in
1515the generated code as described in this document, not the base message
1616classes/interfaces, which are the same in both versions. You should read the
1717[ proto2 language guide] ( /programming-guides/proto ) and/or
18- [ proto3 language guide] ( /programming-guides/proto3 ) before reading this
19- document.
18+ [ proto3 language guide] ( /programming-guides/proto3 )
19+ before reading this document.
2020
2121Note that no Java protocol buffer methods accept or return nulls unless
2222otherwise specified.
@@ -165,9 +165,9 @@ then `Foo` will include fast implementations of all methods, but will implement
165165the ` MessageLite ` interface, which only contains a subset of the methods of
166166` Message ` . In particular, it does not support descriptors or reflection.
167167However, in this mode, the generated code only needs to link against
168- ` libprotobuf-lite.jar ` instead of ` libprotobuf.jar ` . The "lite" library is
169- much smaller than the full library, and is more appropriate for
170- resource-constrained systems such as mobile phones.
168+ ` libprotobuf-lite.jar ` instead of ` libprotobuf.jar ` . The "lite" library is much
169+ smaller than the full library, and is more appropriate for resource-constrained
170+ systems such as mobile phones.
171171
172172The ` Message ` interface defines methods that let you check, manipulate, read, or
173173write the entire message. In addition to these methods, the ` Foo ` class defines
@@ -288,8 +288,8 @@ that modify the value are defined in the builder only.
288288
289289Note that method names always use camel-case naming, even if the field name in
290290the ` .proto ` file uses lower-case with underscores
291- ([ as it should] ( /programming-guides/style ) ). The case-conversion works
292- as follows:
291+ ([ as it should] ( /programming-guides/style ) ). The
292+ case-conversion works as follows:
293293
2942941 . For each underscore in the name, the underscore is removed, and the
295295 following letter is capitalized.
@@ -329,7 +329,8 @@ The compiler will generate the following methods only in the message's builder:
329329 ` hasFoo() ` will return ` false ` and ` getFoo() ` will return the default value.
330330
331331For other simple field types, the corresponding Java type is chosen according to
332- the [ scalar value types table] ( /programming-guides/proto#scalar ) .
332+ the
333+ [ scalar value types table] ( /programming-guides/proto#scalar ) .
333334For message and enum types, the value type is replaced with the message or enum
334335class.
335336
@@ -376,7 +377,8 @@ The compiler will generate the following methods only in the message's builder:
376377 ` getFoo() ` will return the default value for the field's type.
377378
378379For other simple field types, the corresponding Java type is chosen according to
379- the [ scalar value types table] ( /programming-guides/proto#scalar ) .
380+ the
381+ [ scalar value types table] ( /programming-guides/proto#scalar ) .
380382For message and enum types, the value type is replaced with the message or enum
381383class.
382384
@@ -427,88 +429,89 @@ the generated [enum type](#enum).
427429For this field definition:
428430
429431``` proto
430- repeated string foo = 1;
432+ repeated string foos = 1;
431433```
432434
433435The compiler will generate the following accessor methods in both the message
434436class and its builder:
435437
436- - ` int getFooCount () ` : Returns the number of elements currently in the field.
437- - ` String getFoo (int index) ` : Returns the element at the given zero-based
438+ - ` int getFoosCount () ` : Returns the number of elements currently in the field.
439+ - ` String getFoos (int index) ` : Returns the element at the given zero-based
438440 index.
439- - ` ProtocolStringList getFooList () ` : Returns the entire field as a
441+ - ` ProtocolStringList getFoosList () ` : Returns the entire field as a
440442 ` ProtocolStringList ` . If the field is not set, returns an empty list.
441443
442444The compiler will generate the following methods only in the message's builder:
443445
444- - ` Builder setFoo (int index, String value) ` : Sets the value of the element at
446+ - ` Builder setFoos (int index, String value) ` : Sets the value of the element at
445447 the given zero-based index.
446- - ` Builder addFoo (String value) ` : Appends a new element to the field with the
448+ - ` Builder addFoos (String value) ` : Appends a new element to the field with the
447449 given value.
448- - ` Builder addAllFoo (Iterable<? extends String> value) ` : Appends all elements
450+ - ` Builder addAllFoos (Iterable<? extends String> value) ` : Appends all elements
449451 in the given ` Iterable ` to the field.
450- - ` Builder clearFoo () ` : Removes all elements from the field. After calling
451- this, ` getFooCount ()` will return zero.
452+ - ` Builder clearFoos () ` : Removes all elements from the field. After calling
453+ this, ` getFoosCount ()` will return zero.
452454
453455For other simple field types, the corresponding Java type is chosen according to
454- the [ scalar value types table] ( /programming-guides/proto#scalar ) .
456+ the
457+ [ scalar value types table] ( /programming-guides/proto#scalar ) .
455458For message and enum types, the type is the message or enum class.
456459
457460#### Repeated Embedded Message Fields
458461
459- For message types, ` setFoo ()` and ` addFoo ()` also accept an instance of the
462+ For message types, ` setFoos ()` and ` addFoos ()` also accept an instance of the
460463message's builder type as the parameter. This is just a shortcut which is
461464equivalent to calling ` .build() ` on the builder and passing the result to the
462465method. There is also an additional generated method:
463466
464- - ` Builder addFoo (int index, Field value) ` : Inserts a new element at the given
465- zero-based index. Shifts the element currently at that position (if any) and
466- any subsequent elements to the right (adds one to their indices).
467+ - ` Builder addFoos (int index, Field value) ` : Inserts a new element at the
468+ given zero-based index. Shifts the element currently at that position (if
469+ any) and any subsequent elements to the right (adds one to their indices).
467470
468471In addition, the compiler generates the following additional accessor methods in
469472both the message class and its builder for message types, allowing you to access
470473the relevant sub-builders:
471474
472- - ` FooOrBuilder getFooOrBuilder (int index) ` : Returns the builder for the
475+ - ` FooOrBuilder getFoosOrBuilder (int index) ` : Returns the builder for the
473476 specified element, if it already exists, or throws
474477 ` IndexOutOfBoundsException ` if not. If this is called from a message class,
475478 it will always return a message (or throw an exception) rather than a
476479 builder. Calling this method on builders will not create a sub-builder for
477480 the field.
478- - ` List<FooOrBuilder> getFooOrBuilderList () ` : Returns the entire field as an
481+ - ` List<FooOrBuilder> getFoosOrBuilderList () ` : Returns the entire field as an
479482 unmodifiable list of builders (if available) or messages if not. If this is
480483 called from a message class, it will always return an immutable list of
481484 messages rather than an unmodifiable list of builders.
482485
483486The compiler will generate the following methods only in the message's builder:
484487
485- - ` Builder getFooBuilder (int index) ` : Returns the builder for the element at
488+ - ` Builder getFoosBuilder (int index) ` : Returns the builder for the element at
486489 the specified index, or throws ` IndexOutOfBoundsException ` if the index is
487490 out of bounds.
488- - ` Builder addFooBuilder (int index) ` : Inserts and returns a builder for a
491+ - ` Builder addFoosBuilder (int index) ` : Inserts and returns a builder for a
489492 default message instance at the specified index. The existing entries are
490493 shifted to higher indices to make room for the inserted builder.
491- - ` Builder addFooBuilder () ` : Appends and returns a builder for a default
494+ - ` Builder addFoosBuilder () ` : Appends and returns a builder for a default
492495 message instance.
493- - ` Builder removeFoo (int index) ` : Removes the element at the given zero-based
496+ - ` Builder removeFoos (int index) ` : Removes the element at the given zero-based
494497 index.
495- - ` List<Builder> getFooBuilderList () ` : Returns the entire field as an
498+ - ` List<Builder> getFoosBuilderList () ` : Returns the entire field as an
496499 unmodifiable list of builders.
497500
498501#### Repeated Enum Fields (proto3 only)
499502
500503The compiler will generate the following additional methods in both the message
501504class and its builder:
502505
503- - ` int getFooValue (int index) ` : Returns the integer value of the enum at the
506+ - ` int getFoosValue (int index) ` : Returns the integer value of the enum at the
504507 specified index.
505- - ` List<java.lang.Integer> getFooValueList () ` : Returns the entire field as a
508+ - ` List<java.lang.Integer> getFoosValueList () ` : Returns the entire field as a
506509 list of Integers.
507510
508511The compiler will generate the following additional method only in the message's
509512builder:
510513
511- - ` Builder setFooValue (int index, int value) ` : Sets the integer value of the
514+ - ` Builder setFoosValue (int index, int value) ` : Sets the integer value of the
512515 enum at the specified index.
513516
514517#### Name Conflicts
@@ -520,15 +523,15 @@ number appended to the end.
520523For these field definitions:
521524
522525``` proto
523- int32 foo_count = 1;
524- repeated string foo = 2;
526+ int32 foos_count = 1;
527+ repeated string foos = 2;
525528```
526529
527530The compiler will first rename them to the following:
528531
529532``` proto
530- int32 foo_count_1 = 1;
531- repeated string foo_2 = 2;
533+ int32 foos_count_1 = 1;
534+ repeated string foos_2 = 2;
532535```
533536
534537The accessor methods will subsequently be generated as described above.
@@ -564,7 +567,8 @@ The compiler will generate the following methods only in the message's builder:
564567 ` getExampleNameCase() ` will return ` EXAMPLENAME_NOT_SET ` .
565568
566569For other simple field types, the corresponding Java type is chosen according to
567- the [ scalar value types table] ( /programming-guides/proto#scalar ) .
570+ the
571+ [ scalar value types table] ( /programming-guides/proto#scalar ) .
568572For message and enum types, the value type is replaced with the message or enum
569573class.
570574
@@ -602,7 +606,8 @@ The compiler will generate the following methods only in the message's builder:
602606
603607## Any
604608
605- Given an [ ` Any ` ] ( /programming-guides/proto3#any ) field like this:
609+ Given an [ ` Any ` ] ( /programming-guides/proto3#any ) field
610+ like this:
606611
607612``` proto
608613import "google/protobuf/any.proto";
@@ -994,8 +999,8 @@ sends requests to a particular `BlockingRpcChannel`.
994999## Plugin Insertion Points {#plugins}
9951000
9961001[ Code generator plugins] ( /reference/cpp/api-docs/google.protobuf.compiler.plugin.pb )
997- that want to extend the output of the Java code generator may insert code of
998- the following types using the given insertion point names.
1002+ that want to extend the output of the Java code generator may insert code of the
1003+ following types using the given insertion point names.
9991004
10001005- ` outer_class_scope ` : Member declarations that belong in the file's wrapper
10011006 class.
0 commit comments