*/
protected static final Log logger = LogFactory.getLog(BankQuotesAggregationLogic.class);
public static MuleEvent aggregateEvents(EventGroup events) throws Exception
{
LoanQuote lowestQuote = null;
LoanQuote quote = null;
MuleEvent event = null;
for (Iterator iterator = events.iterator(); iterator.hasNext();)
{
event = (MuleEvent)iterator.next();
Object o = event.getMessage().getPayload();
if(o instanceof LoanQuote)
{
quote = (LoanQuote)o;
}
else
{
throw new IllegalArgumentException("Object received by Aggregator is not of expected type. Wanted: "
+ LoanQuote.class.getName() + " Got: " + o);
}
logger.info(LocaleMessage.processingQuote(quote));
if (lowestQuote == null)
{
lowestQuote = quote;
}
else
{
if (quote.getInterestRate() < lowestQuote.getInterestRate())
{
lowestQuote = quote;
}
}
}