public String getHostname(KeeperRecord record) {

        // Prefer standard login field
        Hosts hostsField = getField(record, Hosts.class, null);
        if (hostsField != null)
            return getSingleStringValue(hostsField.getValue(), Host::getHostName);

        // Next, try a PAM hostname
        PamHostnames pamHostsField = getField(record, PamHostnames.class, null);
        if (pamHostsField != null)
            return getSingleStringValue(pamHostsField.getValue(), Host::getHostName);

        KeeperRecordData data = record.getData();
        List<KeeperRecordField> custom = data.getCustom();

        // Use text "hostname" custom field as fallback ...
        Text textField = getField(custom, Text.class, HOSTNAME_LABEL_PATTERN);
        if (textField != null)
            return getSingleStringValue(textField.getValue());

        // ... or hidden "hostname" custom field
        HiddenField hiddenField = getField(custom, HiddenField.class, HOSTNAME_LABEL_PATTERN);
        if (hiddenField != null)
            return getSingleStringValue(hiddenField.getValue());

        return null;

    }
Returns the single hostname (or address) associated with the given
record. If the record has no associated hostname, or multiple hostnames,
null is returned. Hostnames are retrieved from "Hosts" or "PamHostnames"
fields, as well as "Text" and "Hidden" fields that have the label
"hostname", "address", or "ip address" (case-insensitive, space optional).
These field types are checked in the above order, and the first matching
field is returned.

@param record
    The record to retrieve the hostname from.

@return
    The hostname associated with the given record, or null if the record
    has no associated hostname or multiple hostnames.
extensions/guacamole-vault/modules/guacamole-vault-ksm/src/main/java/org/apache/guacamole/vault/ksm/secret/KsmRecordService.java