code: private void generateEncode(TypeToken<?> outputType, Schema schema) {
      TypeToken<?> callOutputType = getCallTypeToken(outputType, schema);
  
      Method encodeMethod = getMethod(void.class, "encode", callOutputType.getRawType(), Encoder.class);
  
      if (!Object.class.equals(callOutputType.getRawType())) {
        // Generate the synthetic method for the bridging
        Method method = getMethod(void.class, "encode", Object.class, Encoder.class);
        GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC + Opcodes.ACC_BRIDGE + Opcodes.ACC_SYNTHETIC,
                                                   method, null, new Type[] {Type.getType(IOException.class)},
                                                   classWriter);
  
        mg.loadThis();
        mg.loadArg(0);
        mg.checkCast(Type.getType(callOutputType.getRawType()));
        mg.loadArg(1);
        mg.invokeVirtual(classType, encodeMethod);
        mg.returnValue();
        mg.endMethod();
      }
  
      // Generate the top level public encode method
      String methodSignature = null;
      if (callOutputType.getType() instanceof ParameterizedType) {
        methodSignature = Signatures.getMethodSignature(encodeMethod, new TypeToken[]{callOutputType, null});
      }
      GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC, encodeMethod, methodSignature,
                                new Type[] {Type.getType(IOException.class)}, classWriter);
  
      // Delegate to the actual encode method(value, encoder, schema, Sets.newIdentityHashSet());
      mg.loadThis();
      mg.loadArg(0);
      mg.loadArg(1);
      mg.loadThis();
      mg.getField(classType, "schema", Type.getType(Schema.class));
      // seenRefs Set
      mg.invokeStatic(Type.getType(Sets.class), getMethod(Set.class, "newIdentityHashSet"));
      mg.invokeVirtual(classType, getEncodeMethod(outputType, schema));
      mg.returnValue();
      mg.endMethod();
    }
docs: Generates the {@link DatumWriter#encode(Object, co.cask.tigon.io.Encoder)} method.
  @param outputType Type information of the data type for output
  @param schema Schema to use for output.