class HasMailAttributeWithValueRegex extends GenericMatcher {

    @Override
    public Collection<MailAddress> match(Mail mail) throws MessagingException {
        return AttributeUtils
            .getAttributeValueFromMail(mail, attributeName)
            .filter(obj -> pattern.matcher(obj.toString()).matches())
            .map(any -> mail.getRecipients())
            .orElse(null);
    }

}