Class OldCompletePreferenceImpl

  • Direct Known Subclasses:
    OldLinearPreferenceImpl

    public class OldCompletePreferenceImpl
    extends Object
    Immutable class. A Preference represents a list of alternatives, sorted by order of preference. Two alternatives can be equally ranked. There cannot be twice the same alternative.
    • Constructor Detail

      • OldCompletePreferenceImpl

        protected OldCompletePreferenceImpl​(List<Set<Alternative>> preference)
        Parameters:
        preferences - not null a list of sets of alternatives. In a set, the alternatives are equally ranked. The sets are sorted by preference in the list. If an alternative is present several times, an IllegalArgumentException is thrown.
    • Method Detail

      • getPreferencesNonStrict

        public List<Set<Alternative>> getPreferencesNonStrict()
        Returns:
        the preference of alternatives
      • size

        public int size()
        Returns:
        the size of the Preference, i.e. the number of alternatives in the Preference
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • contains

        public boolean contains​(Alternative alter)
        Parameters:
        alter - not null
        Returns:
        whether the preference contains the alternative given as parameter
      • hasSameAlternatives

        public boolean hasSameAlternatives​(OldCompletePreferenceImpl p)
        Parameters:
        p - not null
        Returns:
        whether the preferences are about the same alternatives exactly (not necessarily in the same order).
      • isIncludedIn

        public boolean isIncludedIn​(OldCompletePreferenceImpl p)
        Parameters:
        p - not null
        Returns:
        whether the parameter preference contains all the alternatives in the calling preference
      • getAlternativeRank

        public int getAlternativeRank​(Alternative alter)
        Parameters:
        alter - not null. If the alternative is not in the preference, it throws an IllegalArgumentException.
        Returns:
        the rank of the alternative given in the Preference.
      • toAlternativeSet

        public static Set<Alternative> toAlternativeSet​(List<Set<Alternative>> preference)
        Parameters:
        preferences - not null a list of sets of alternatives
        Returns:
        a set of alternatives containing all the alternatives of the list of set of alternative given. If an alternative appears several times in the list of sets, it appears only once in the new set.
      • size

        public static int size​(List<Set<Alternative>> list)
        Parameters:
        list - not null
        Returns:
        the size of a list of alternative sets
      • createCompletePreferenceImpl

        public static OldCompletePreferenceImpl createCompletePreferenceImpl​(List<Set<Alternative>> preference)
        Factory method for CompletePreferenceImpl
        Parameters:
        preference - not null and all alternatives differents
        Returns:
        a new CompletePreferenceImpl
      • isStrict

        public boolean isStrict()
        Returns:
        true if the Preference is Strict (without several alternatives having the same rank)
      • toStrictPreference

        public OldLinearPreferenceImpl toStrictPreference()
        Returns:
        the StrictPreference built from the preference if the preference is strict. If the preference is not strict it throws an IllegalArgumentException.