001package de.deepamehta.plugins.mail; 002 003import java.io.UnsupportedEncodingException; 004import java.util.ArrayList; 005import java.util.HashMap; 006import java.util.List; 007 008import javax.mail.internet.AddressException; 009import javax.mail.internet.InternetAddress; 010 011/** 012 * Hash recipient lists by type. 013 */ 014@SuppressWarnings("serial") 015class RecipientsByType extends HashMap<RecipientType, List<InternetAddress>> { 016 017 private Integer count = 0; 018 019 public void add(String typeUri, String address, String personal) 020 throws UnsupportedEncodingException, AddressException { 021 InternetAddress internetAddress = new InternetAddress(address, personal); 022 internetAddress.validate(); 023 getTypeList(RecipientType.fromUri(typeUri)).add(internetAddress); 024 count++; 025 } 026 027 private List<InternetAddress> getTypeList(RecipientType type) { 028 if (get(type) == null) { 029 put(type, new ArrayList<InternetAddress>()); 030 } 031 return get(type); 032 } 033 034 public Integer getCount() { 035 return count; 036 } 037}