Interface Bazaar<T>

  • Type Parameters:
    T - the type of product create by this Bazaar
    All Known Implementing Classes:
    BazaarImpl, ThreadSafeBazaar

    public interface Bazaar<T>
    A Bazaar is a flexible registry for factories to create specific objects of type T, called "product". To create a product, an arbitrary number of Vendor is queried. Vendor request certain parameters to create a product. This is queried from the BazaarContext. If a AllPermission parameters requested by a Vendor are present in the BazaarContext, a Vendor will do a Bid. The Vendor with the highest Bid will finally create a product. If two or more Vendor do the same bid, the registered Bazaar.PriorityOverlapCallBack will be notified, an arbitrary Vendor with the same Bid will create the product in this case. To transform parameter in the BazaarContext into parameters Vendors expect, you can register BazaarContextFunctions at the Bazaar.
    Author:
    jonas
    • Method Detail

      • addVendor

        void addVendor​(Vendor<? extends T> vendor)
        Adds a Vendor to the bazaar. Will be queried if a product is requested, the best fitting will create the product. Has no effect if the vendor is already present in this bazaar.
        Parameters:
        vendor - the Vendor
      • removeVendor

        void removeVendor​(Vendor<? extends T> vendor)
        Removes a Vendor from the bazaar. Has no effect if the vendor is not present in this bazaar.
        Parameters:
        vendor - the Vendor to remove
      • createProducts

        java.util.List<T> createProducts​(BazaarContext context)
        Creates a list of products of type T, provided by Vendors which are statisfied by the parameters in the BazaarContext, ordered by their Bid. Ties are not broken as all bids are successful and are used only for ordering.
        Parameters:
        context - the BazaarContext, which is used to provide requested parameters for Vendor
        Returns:
        a list of products ordered by the highest Bid