private <T extends KeeperRecordField> T getField(KeeperRecord record,
            Class<T> fieldClass, Pattern labelPattern) {

        KeeperRecordData data = record.getData();

        // Attempt to find standard field first, ignoring custom fields if a
        // standard field exists (NOTE: standard fields do not have labels)
        T field = getField(data.getFields(), fieldClass, null);
        if (field != null)
            return field;

        // Fall back on custom fields
        return getField(data.getCustom(), fieldClass, labelPattern);

    }
Returns the instance of the only field that has the given type and
matches the given label pattern. If there are no such fields, or
multiple such fields, null is returned. Both standard and custom fields
are searched. As standard fields do not have labels, any given label
pattern is ignored for standard fields.

@param <T>
    The type of field to return.

@param record
    The Keeper record to retrieve the field from.

@param fieldClass
    The class representing the type of field to return.

@param labelPattern
    The pattern to match against the labels of custom fields, or null if
    no label pattern match should be performed.

@return
    The field having the given type and matching the given label
    pattern, or null if there is not exactly one such field.
extensions/guacamole-vault/modules/guacamole-vault-ksm/src/main/java/org/apache/guacamole/vault/ksm/secret/KsmRecordService.java