code: public byte[] toBytes(final DefinedRuntimes definedRuntimes){
      final DatumWriter<DefinedRuntimes> configurationWriter =
              new SpecificDatumWriter<>(DefinedRuntimes.class);
      try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        final BinaryEncoder binaryEncoder = EncoderFactory.get().binaryEncoder(out, null);
        configurationWriter.write(definedRuntimes, binaryEncoder);
        binaryEncoder.flush();
        out.flush();
        return out.toByteArray();
      } catch (final IOException e) {
        throw new RuntimeException("Unable to serialize DefinedRuntimes", e);
      }
    }
docs: Serializes DefinedRuntimes.
  @param definedRuntimes the Avro object to toString
  @return Serialized avro string