class MessageAttributeSetters {

    public static void applyAll(final IObject attributes, final IObject context, final SMTPMessageAdaptor to)
            throws AttributeSetterException {
        Iterator<Map.Entry<IFieldName, Object>> iterator = attributes.iterator();

        while (iterator.hasNext()) {
            Map.Entry<IFieldName, Object> entry = iterator.next();
            try {
                settersMap.get(entry.getKey().toString()).setOn(to, context, entry.getValue());
            } catch (NullPointerException e) {
                throw new AttributeSetterException("Setter not found", e);
            } catch (MessagingException | ReadValueException | ChangeValueException e) {
                throw new AttributeSetterException("Failed to set attribute", e);
            }
        }
    }

}