
io.github.oliviercailloux.j_voting.profiles.ImmutableProfile Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of j-voting Show documentation
Show all versions of j-voting Show documentation
General classes for dealing with social choice theory.
The newest version!
package io.github.oliviercailloux.j_voting.profiles;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions;
import io.github.oliviercailloux.j_voting.Alternative;
import io.github.oliviercailloux.j_voting.OldCompletePreferenceImpl;
import io.github.oliviercailloux.j_voting.Voter;
/**
* This class is immutable. Represents a Complete Profile.
*/
public class ImmutableProfile extends ImmutableProfileI implements Profile {
private static final Logger LOGGER = LoggerFactory.getLogger(ImmutableProfile.class.getName());
/**
* Factory method for ImmutableProfile
*
* @param votes not null
* @return new ImmutableProfile
*/
public static ImmutableProfile createImmutableProfile(Map votes) {
LOGGER.debug("Factory ImmutableProfile");
Preconditions.checkNotNull(votes);
return new ImmutableProfile(votes);
}
private ImmutableProfile(Map votes) {
super(checkCompleteMap(votes));
}
@Override
public Set getAlternatives() {
LOGGER.debug("getAlternatives:");
OldCompletePreferenceImpl p = votes.values().iterator().next();
return OldCompletePreferenceImpl.toAlternativeSet(p.getPreferencesNonStrict());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy