FieldGen
One field, with every decision the printers need already made.
The reason this is a class rather than a pile of functions on FieldDescriptor is that most of the decisions - presence, packing, the Scala type, whether a TypeMapper is in play - are interdependent, and computing them once keeps the printers free of conditionals.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Value members
Concrete methods
The name of the per-instance cache of this field's base value.
The name of the per-instance cache of this field's base value.
Attributes
Whether the field's element is a message, generated here or protobuf's own.
Whether the field's element is a message, generated here or protobuf's own.
Attributes
The test that decides whether an implicit-presence field is written.
The test that decides whether an implicit-presence field is written.
Floats compare by raw bits rather than by value, because -0.0 == 0.0 and a value comparison would silently drop the sign of a negative zero.
Attributes
Reads one element and maps it to the field's Scala type.
Reads one element and maps it to the field's Scala type.
Attributes
Reads one base-typed element.
Reads one base-typed element.
Attributes
Size of one element without its tag, for the packed encoding.
Size of one element without its tag, for the packed encoding.
Attributes
Size of one element including its tag, given an expression for the base value.
Size of one element including its tag, given an expression for the base value.
Attributes
Converts a Scala-typed expression back to the base type.
Converts a Scala-typed expression back to the base type.
Attributes
Writes one element, tag included.
Writes one element, tag included.
Attributes
A value to give the field in defaultInstance when it has no constructor default.
A value to give the field in defaultInstance when it has no constructor default.
Only reached for a required or no_box field: those deliberately have no default in the constructor, so that forgetting one is a compile error, but defaultInstance still has to produce something.
Attributes
Concrete fields
The other tag a parser must also accept for a packable repeated field.
The other tag a parser must also accept for a packable repeated field.
protobuf requires readers to accept both encodings whatever the schema says, because the schema may have changed since the bytes were written.
Attributes
The Scala type of one element at the proto level, before any mapping.
The Scala type of one element at the proto level, before any mapping.
Attributes
The field's declared Scala type, collections and Option included.
The field's declared Scala type, collections and Option included.
Attributes
The default for the constructor parameter, or None when there must not be one.
The default for the constructor parameter, or None when there must not be one.
Attributes
The Scala type of one element as it appears in the generated API.
The Scala type of one element as it appears in the generated API.
Attributes
Whether parsing must fail when the field is absent.
Whether parsing must fail when the field is absent.
Attributes
Whether the field tracks presence, i.e. whether its Scala type is an Option.
Whether the field tracks presence, i.e. whether its Scala type is an Option.
Asks the descriptor rather than the syntax. hasPresence is resolved from the edition's field_presence feature for an editions file, from optional/required for proto2 and from the optional keyword for proto3, so one question covers all three.
Attributes
Whether the field's Scala type is wrapped in Option.
Whether the field's Scala type is wrapped in Option.
Presence is necessary but not sufficient. A required field has presence - protobuf tracks whether it was set, and rejects a message where it was not - yet wrapping it would be backwards: the whole point is that it is always there. It gets a bare type and no constructor default instead, so omitting it is a compile error. no_box says the same thing for a field the schema cannot mark required.
Attributes
Whether a repeated field uses the packed encoding, resolved from the features.
Whether a repeated field uses the packed encoding, resolved from the features.
Attributes
proto2's required, and editions' LEGACY_REQUIRED.
proto2's required, and editions' LEGACY_REQUIRED.
Attributes
The TypeMapper expression, when the element's Scala type is not the base type.
The TypeMapper expression, when the element's Scala type is not the base type.
Attributes
The Scala name, from (field).scala_name or the camel-cased proto name.
The Scala name, from (field).scala_name or the camel-cased proto name.
Attributes
The tag protoc writes for this field in its declared encoding.
The tag protoc writes for this field in its declared encoding.