class WithPriority extends GenericMailet {

    @Override
    public void init() throws MessagingException {
        Integer priorityRaw = Optional.ofNullable(getInitParameter("priority", null))
            .map(Integer::valueOf)
            .orElseThrow(() -> new IllegalArgumentException("'priority' init parameter is compulsory"));

        if (priorityRaw < 0 || priorityRaw > 9) {
            throw new IllegalArgumentException("Invalid priority: Priority should be from 0 to 9");
        }
        priority = new Attribute(MailPrioritySupport.MAIL_PRIORITY, AttributeValue.of(priorityRaw));
    }

}