* This distribution policy determines the sector of the stock and
* picks the slice of the given list of slices at ordinal index of the
* enumerated Sector.
*/
public String distribute(Object pc, List<String> slices, Object context) {
Stock stock = null;
if (pc instanceof Tradable) {
stock = ((Tradable)pc).getStock();
} else if (pc instanceof Stock) {
stock = (Stock)pc;
} else if (pc instanceof Trade) {
stock = ((Trade)pc).getStock();
} else if (pc instanceof Trader) {
throw new IllegalArgumentException("Trader should have been replicated");
}
return stock != null ? slices.get(stock.getSector().ordinal()) : null;
}