Class Selector

  • All Implemented Interfaces:
    ISelector

    public class Selector
    extends java.lang.Object
    implements ISelector
    Default selector implementation for evaluating a set of proposals. The proposals will be first tested on acceptability. In the second (optional) step they will be sorted according to the specified comparator/comparable. In the third step a (sub)set will be filtered out according to the specified number chooseable of resuls (choose).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ALL
      The constant for specifiying that all proposals should be chosen.
      protected java.util.Comparator comp
      The comparator for comparing proposals.
      protected int max_winners
      The max number of proposals to be chosen.
      static int ONE
      The constant for specifiying that one proposal should be chosen.
    • Constructor Summary

      Constructors 
      Constructor Description
      Selector()
      Create a new selector.
      Selector​(int max_winners)
      Create a new selector.
      Selector​(java.util.Comparator comp)
      Create a new selector.
      Selector​(java.util.Comparator comp, int max_winners)
      Create a new selector.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.Object[] determineAcceptableProposals​(java.lang.Object[] proposals)
      Get all acceptable proposals.
      protected java.lang.Object[] determineWinners​(java.lang.Object[] proposals)
      Select proposals.
      boolean isAcceptable​(java.lang.Object proposal)
      Test if a proposal is acceptable.
      java.lang.Object[] select​(java.lang.Object[] proposals)
      Select proposals.
      protected void sortProposals​(java.lang.Object[] proposals)
      Sort the proposals.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ALL

        public static final int ALL
        The constant for specifiying that all proposals should be chosen.
        See Also:
        Constant Field Values
      • ONE

        public static final int ONE
        The constant for specifiying that one proposal should be chosen.
        See Also:
        Constant Field Values
      • comp

        protected java.util.Comparator comp
        The comparator for comparing proposals.
      • max_winners

        protected int max_winners
        The max number of proposals to be chosen.
    • Constructor Detail

      • Selector

        public Selector()
        Create a new selector.
      • Selector

        public Selector​(java.util.Comparator comp)
        Create a new selector.
        Parameters:
        comp - The optional comparator for sorting proposals.
      • Selector

        public Selector​(int max_winners)
        Create a new selector.
        Parameters:
        max_winners - The number of proposals to be chosen at most.
      • Selector

        public Selector​(java.util.Comparator comp,
                        int max_winners)
        Create a new selector.
        Parameters:
        comp - The optional comparator for sorting proposals.
        max_winners - The number of proposals to be chosen at most.
    • Method Detail

      • select

        public java.lang.Object[] select​(java.lang.Object[] proposals)
        Select proposals.
        Specified by:
        select in interface ISelector
        Parameters:
        proposals - The proposals.
        Returns:
        The selected proposal(s) or none. todo: include information about negotiation history?
      • determineAcceptableProposals

        protected java.lang.Object[] determineAcceptableProposals​(java.lang.Object[] proposals)
        Get all acceptable proposals.
        Parameters:
        proposals - The proposals.
        Returns:
        The acceptable proposals.
      • sortProposals

        protected void sortProposals​(java.lang.Object[] proposals)
        Sort the proposals.
        Parameters:
        proposals - The proposals to sort.
      • determineWinners

        protected java.lang.Object[] determineWinners​(java.lang.Object[] proposals)
        Select proposals.
        Parameters:
        proposals - The proposals.
        Returns:
        The selected proposals.
      • isAcceptable

        public boolean isAcceptable​(java.lang.Object proposal)
        Test if a proposal is acceptable.
        Parameters:
        proposal - The proposal.
        Returns:
        True, if proposal is acceptable.