T
- the type of product produced by this Bazaar
public class BazaarImpl<T> extends Object implements Bazaar<T>
Bazaar
using the IEclipseContext
for dependency injection.Bazaar.Builder<T>, Bazaar.PriorityOverlapCallBack<T>
Constructor and Description |
---|
BazaarImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addContextFunction(String key,
BazaarContextFunction contextFunction)
Adds a
BazaarContextFunction to this Bazaar to exchange existing parameters to a parameter
requested by a Vendor . |
org.eclipse.e4.core.contexts.IEclipseContext |
addContextFunctions(org.eclipse.e4.core.contexts.IEclipseContext context)
Transforms all
BazaarContextFunction s to IContextFunction s and attaches those to an
IEclipseContext . |
void |
addVendor(Vendor<? extends T> vendor)
Adds a
Vendor to the bazaar. |
boolean |
checkPreConditions(Vendor<? extends T> vendor,
org.eclipse.e4.core.contexts.IEclipseContext context)
Checks the
Precondition s for a given vendor. |
org.eclipse.e4.core.contexts.IEclipseContext |
createEclipseContext(BazaarContext bazaarContext)
Creates an
IEclipseContext from a BazaarContext . |
T |
createProduct(BazaarContext bazaarContext)
Creates a product of type T, provided by the
Vendor with the highest Bid and which is statisfied
by the parameters in the BazaarContext . |
T |
createProduct(Vendor<? extends T> vendor,
org.eclipse.e4.core.contexts.IEclipseContext context)
Returns the product which is provided with the highest priority by any
Vendor . |
List<T> |
createProducts(BazaarContext bazaarContext)
Creates a list of products of type T, provided by
Vendor s which are statisfied by the parameters in the
BazaarContext , ordered by their Bid . |
Vendor<? extends T> |
getBestVendor(org.eclipse.e4.core.contexts.IEclipseContext context) |
void |
removeVendor(Vendor<? extends T> vendor)
Removes a
Vendor from the bazaar. |
void |
setPriorityOverlapCallBack(Bazaar.PriorityOverlapCallBack<? super T> priorityOverlapCallBack)
|
public void addVendor(Vendor<? extends T> vendor)
Bazaar
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.public void removeVendor(Vendor<? extends T> vendor)
Bazaar
Vendor
from the bazaar. Has no effect if the vendor
is not present in this bazaar.removeVendor
in interface Bazaar<T>
vendor
- the Vendor
to removepublic T createProduct(Vendor<? extends T> vendor, org.eclipse.e4.core.contexts.IEclipseContext context)
Vendor
.public org.eclipse.e4.core.contexts.IEclipseContext addContextFunctions(org.eclipse.e4.core.contexts.IEclipseContext context)
BazaarContextFunction
s to IContextFunction
s and attaches those to an
IEclipseContext
.context
- the IEclipseContext
to attache IContextFunction
s toIEclipseContext
with attached IContextFunction
public org.eclipse.e4.core.contexts.IEclipseContext createEclipseContext(BazaarContext bazaarContext)
IEclipseContext
from a BazaarContext
. If the
bazaar context contains an Eclipse context, then it is used and will have
all other values set into it from the bazaar context.bazaarContext
- the BazaarContext
to get key / values fromIEclipseContext
containign all key / values provided by the BazaarContext
public Vendor<? extends T> getBestVendor(org.eclipse.e4.core.contexts.IEclipseContext context)
context
- the Eclipse injection contextcontext
public void setPriorityOverlapCallBack(Bazaar.PriorityOverlapCallBack<? super T> priorityOverlapCallBack)
Bazaar
setPriorityOverlapCallBack
in interface Bazaar<T>
priorityOverlapCallBack
- a PriorityOverlapCallBackpublic void addContextFunction(String key, BazaarContextFunction contextFunction)
Bazaar
BazaarContextFunction
to this Bazaar
to exchange existing parameters to a parameter
requested by a Vendor
.addContextFunction
in interface Bazaar<T>
key
- contextFunction
- public T createProduct(BazaarContext bazaarContext)
Bazaar
Vendor
with the highest Bid
and which is statisfied
by the parameters in the BazaarContext
. In case of tied bids, the Bazaar.PriorityOverlapCallBack
if one is set will be notified of which vendor is chosen to break the tie. Note that during the
bidding process, ties may have to be broken in this way that are later defeated by a higher bid.createProduct
in interface Bazaar<T>
bazaarContext
- the BazaarContext
, which is used to provide requested parameters for Vendor
Vendor
Bazaar.createProduct(org.eclipse.emfforms.bazaar.BazaarContext)
public List<T> createProducts(BazaarContext bazaarContext)
Bazaar
Vendor
s 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.createProducts
in interface Bazaar<T>
bazaarContext
- the BazaarContext
, which is used to provide requested parameters for Vendor
Bid
Bazaar.createProducts(org.eclipse.emfforms.bazaar.BazaarContext)
public boolean checkPreConditions(Vendor<? extends T> vendor, org.eclipse.e4.core.contexts.IEclipseContext context)
Precondition
s for a given vendor.vendor
- The Vendor
to check the Precondition
for.context
- The IEclipseContext
to provide the Precondition
Precondition
s are fulfilledCopyright © 2019. All rights reserved.