BigDecimal getNumericAspectOfAsset()

in service/src/main/java/org/apache/fineract/cn/stellarbridge/service/internal/horizonadapter/StellarAccountHelpers.java [102:116]


  BigDecimal getNumericAspectOfAsset(
      final Asset asset,
      final Function<Balance, BigDecimal> aspect)
  {
    final Optional<BigDecimal> balanceOfGivenAsset
        = Arrays.stream(account.getBalances())
        .filter(balance -> getAssetOfBalance(balance).equals(asset))
        .map(aspect)
        .max(BigDecimal::compareTo);

    //Theoretically there shouldn't be more than one balance, but if this should turn out to be
    //incorrect, we return the largest one, rather than adding them together.

    return balanceOfGivenAsset.orElse(BigDecimal.ZERO);
  }