public byte[] serialize(RemoteLogMetadata remoteLogMetadata) {

        ApiMessageAndVersion apiMessageAndVersion;
        if (remoteLogMetadata instanceof RemoteLogSegmentMetadata) {
            apiMessageAndVersion = segmentTransform.toApiMessageAndVersion((RemoteLogSegmentMetadata) remoteLogMetadata);
        } else if (remoteLogMetadata instanceof RemoteLogSegmentMetadataUpdate) {
            apiMessageAndVersion = segmentUpdateTransform.toApiMessageAndVersion((RemoteLogSegmentMetadataUpdate) remoteLogMetadata);
        } else if (remoteLogMetadata instanceof RemotePartitionDeleteMetadata) {
            apiMessageAndVersion = partitionDeleteTransform.toApiMessageAndVersion((RemotePartitionDeleteMetadata) remoteLogMetadata);
        } else if (remoteLogMetadata instanceof RemoteLogSegmentMetadataSnapshot) {
            apiMessageAndVersion = segmentSnapshotTransform.toApiMessageAndVersion((RemoteLogSegmentMetadataSnapshot) remoteLogMetadata);
        } else {
            throw new IllegalArgumentException("RemoteLogMetadataTransform for given RemoteStorageMetadata class: " + remoteLogMetadata.getClass()
                    + " does not exist.");
        }

        return bytesApiMessageSerde.serialize(apiMessageAndVersion);
    }
This class provides serialization and deserialization for {@link RemoteLogMetadata}. This is the root serde
for the messages that are stored in internal remote log metadata topic.
storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/serialization/RemoteLogMetadataSerde.java