docs: private LocalVariableDefinition buildUnion(MethodDefinition read, Map<Short, LocalVariableDefinition> unionData)
      {
          // construct the instance and store it in the instance local variable
          LocalVariableDefinition instance = constructUnionInstance(read);
  
          // switch (fieldId)
          read.loadVariable("fieldId");
  
          List<CaseStatement> cases = new ArrayList<>();
          for (ThriftFieldMetadata field : metadata.getFields(THRIFT_FIELD)) {
              cases.add(caseStatement(field.getId(), field.getName() + "-inject-field"));
          }
          read.switchStatement("inject-default", cases);
  
          for (ThriftFieldMetadata field : metadata.getFields(THRIFT_FIELD)) {
              // case field.id:
              read.visitLabel(field.getName() + "-inject-field");
  
              injectField(read, field, instance, unionData.get(field.getId()));
  
              if (field.getMethodInjection().isPresent()) {
                  injectMethod(read, field.getMethodInjection().get(), instance, unionData);
              }
  
              read.gotoLabel("inject-default");
          }
  
          // default case
          read.visitLabel("inject-default");
  
          // find the @ThriftUnionId field
          ThriftFieldMetadata idField = getOnlyElement(metadata.getFields(THRIFT_UNION_ID));
  
          injectIdField(read, idField, instance, unionData);
  
          // invoke factory method if present
          invokeFactoryMethod(read, unionData, instance);
  
          return instance;
      }