package gw.currency uses gw.pl.currency.MonetaryAmount uses gw.util.GosuObjectUtil uses java.util.Arrays @ReadOnly enhancement GWArrayMonetaryAmountSumCoreEnhancement : T[] { /** * Return the average of the values of the target of the mapper argument, * which must all be of the same currency as specified. */ reified function average( currency : Currency, select:block(elt:T):MonetaryAmount) : MonetaryAmount { return getList().average( currency, select ) } /** * Sums up the values of the target of the mapper argument, * which must all be of the same currency as specified. */ function sum( currency : Currency, mapper(elt:T) : MonetaryAmount ) : MonetaryAmount { return getList().sum( currency, mapper ) } // Cribbed from CoreArrayEnhancement.gsx:fastList() // Can't directly use fastList() as it is an internal function private function getList() : java.util.List { if (GosuObjectUtil.isJavaReferenceArray(this)) { return Arrays.asList(this) } else { return this.toList() } } }