OneofGen

nscn.polaris2.protoc.codegen.OneofGen
final class OneofGen(val od: OneofDescriptor, val ctx: GenContext, ownerName: String)

Emits a proto oneof as a nested Scala 3 enum.

This is the shape that makes a oneof pleasant to use: exhaustive matching, no "which getter is valid" question, and an explicit Empty case instead of a null.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def caseName(field: FieldGen): String

The case name for one member.

The case name for one member.

A field actually called empty would otherwise collide with the Empty case, so it gets a trailing underscore rather than a compile error in generated code.

Attributes

def getFieldArms: Seq[String]

getFieldByNumber arms: Some only while that member's case is active.

getFieldByNumber arms: Some only while that member's case is active.

Attributes

def parseCasesByTag(varName: String): Seq[(Int, Seq[String])]

Parse arms, keyed by tag.

Parse arms, keyed by tag.

A message-typed member merges with the previous value when the same case repeats, which is protobuf's rule for a singular message field appearing twice.

Attributes

def sizeStatements: Seq[String]

Sizes the active case, if any. A oneof member is written even when it is the default.

Sizes the active case, if any. A oneof member is written even when it is the default.

Attributes

def writeStatementsByNumber: Seq[(Int, Seq[String])]

One guarded write per member, keyed by field number.

One guarded write per member, keyed by field number.

Per member rather than one match, so the enclosing message can interleave them with its other fields in field-number order. A oneof's members need not be contiguous.

Attributes

Concrete fields

val members: Seq[FieldGen]
val od: OneofDescriptor
val scalaName: String

The field name on the enclosing message.

The field name on the enclosing message.

Attributes

val typeName: String

The name of the generated enum.

The name of the generated enum.

Attributes