List of usage examples for org.apache.commons.collections.primitives LongList contains
boolean contains(long element);
true
iff I contain the specified element. From source file:architecture.ee.web.community.poll.DefaultPollManager.java
public List<PollOption> getAnomymousVotes(Poll poll, String username) { if (username == null) throw new IllegalArgumentException("user unique id cannot be null."); List<Vote> votes = getVotes(poll); LongList list = new ArrayLongList(); List<PollOption> options = new ArrayList<PollOption>(); for (Vote vote : votes) { if (username.equals(vote.getUniqueId()) && !list.contains(vote.getOptionId())) { list.add(vote.getOptionId()); }//w w w.jav a 2 s .c o m } for (PollOption option : poll.getOptions()) { if (list.contains(option.getOptionId())) options.add(option); } return options; }
From source file:architecture.ee.web.community.poll.DefaultPollManager.java
public List<PollOption> getUserVotes(Poll poll, User user) { if (user == null) throw new IllegalArgumentException("user cannot be null."); List<Vote> votes = getVotes(poll); LongList list = new ArrayLongList(); List<PollOption> options = new ArrayList<PollOption>(); for (Vote vote : votes) { if (vote.getUserId() == user.getUserId() && !list.contains(vote.getOptionId())) { list.add(vote.getOptionId()); }/*from w w w . j a v a 2s . c om*/ } for (PollOption option : poll.getOptions()) { if (list.contains(option.getOptionId())) options.add(option); } return options; }