public void save(Campaign campaign) { if (campaign.getId() == null) { Integer id = NEXT_ID.getAndIncrement(); campaign.setId(id); } campaigns.put(campaign.getId(), campaign); }
public Set<Campaign> findByAdvertiserId(int advertiserId) { Set<Campaign> results = newHashSet(); Iterator<Campaign> campaignsIter = campaigns.values().iterator(); while (campaignsIter.hasNext()) { Campaign campaign = campaignsIter.next(); if (campaign.getAdvertiser().getId().equals(advertiserId)) { results.add(campaign); } } return results; }