class EndpointCertificateMetadataSerializer {

    public static Slime toSlime(EndpointCertificateMetadata metadata) {
        Slime slime = new Slime();
        Cursor object = slime.setObject();
        object.setString(keyNameField, metadata.keyName());
        object.setString(certNameField, metadata.certName());
        object.setLong(versionField, metadata.version());
        object.setLong(lastRequestedField, metadata.lastRequested());

        metadata.request_id().ifPresent(id -> object.setString(requestIdField, id));
        metadata.requestedDnsSans().ifPresent(sans -> {
            Cursor cursor = object.setArray(requestedDnsSansField);
            sans.forEach(cursor::addString);
        });
        metadata.issuer().ifPresent(id -> object.setString(issuerField, id));

        return slime;
    }

}