/**
 * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.financial.aggregation;

import com.opengamma.core.position.Position;
import com.opengamma.financial.security.FinancialSecurityUtils;
import com.opengamma.util.money.Currency;

/**
 * Function to classify positions by Currency.
 *
 */
public class CurrencyAggregationFunction implements AggregationFunction<Currency> {
  private static final String NAME = "Currency";
  
  @Override
  public Currency classifyPosition(Position position) {
    return FinancialSecurityUtils.getCurrency(position.getSecurity());
  }

  public String getName() {
    return NAME;
  }
}

@@ -471,16 +471,17 @@
 ency%3E %7B%0A
+%0A
   privat
@@ -588,24 +588,36 @@
 position) %7B%0A
+    try %7B%0A  
     return F
@@ -675,16 +675,90 @@
 ity());%0A
+    %7D catch (UnsupportedOperationException ex) %7B%0A      return null;%0A    %7D%0A
   %7D%0A%0A  p

Translate exceptions from FinancialSecurityUtils to NULL.