code: private void appendPortableWriter(JMessage<?> message) {
          writer.appendln("@Override")
                .formatln("public void writePortable(%s %s) throws %s {",
                          PortableWriter.class.getName(),
                          PORTABLE_WRITER,
                          IOException.class.getName())
                .begin();
          // TODO: This should be short[] instead, as field IDs are restricted to 16bit.
          writer.appendln("int[] setFields = presentFields().stream()")
                .appendln("                                 .mapToInt(_Field::getId)")
                .appendln("                                 .toArray();")
                .appendln("portableWriter.writeIntArray(\"__fields__\", setFields);");
          for (JField field : message.declaredOrderFields()) {
              if (!field.alwaysPresent()) {
                  writer.formatln("if( %s() ) {", field.isSet())
                        .begin();
              }
              writePortableField(field);
              if (!field.alwaysPresent()) {
                  writer.end()
                        .appendln("} else {")
                        .begin();
                  writeDefaultPortableField(field);
                  writer.end()
                        .appendln("}");
              }
          }
          writer.end()
                .appendln("}")
                .newline();
      }
docs: Method to append writePortable from hazelcast_portable.
  
  @param message JMessage with the information.
  <pre>
  {@code
  public void writePortable(com.hazelcast.nio.serialization.PortableWriter portableWriter) throws java.io.IOException {
  ...
  portableWriter.writeByteArray("__hzOptionalsForClassOptionalFields", optionals.toByteArray());
  }
  }
  </pre>