Example usage for org.apache.commons.collections.primitives LongList contains

List of usage examples for org.apache.commons.collections.primitives LongList contains

Introduction

In this page you can find the example usage for org.apache.commons.collections.primitives LongList contains.

Prototype

boolean contains(long element);

Source Link

Document

Returns true iff I contain the specified element.

Usage

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;
}