CurrencyAmount implements ImmutableBean, Serializable { @FromString public static CurrencyAmount parse(final String amountStr) { ArgumentChecker.notNull(amountStr, "amountStr"); String[] parts = StringUtils.split(amountStr, ' '); if (parts.length != 2) { throw new IllegalArgumentException("Unable to parse amount, invalid format: " + amountStr); } try { Currency cur = Currency.parse(parts[0]); double amount = Double.parseDouble(parts[1]); return new CurrencyAmount(cur, amount); } catch (RuntimeException ex) { throw new IllegalArgumentException("Unable to parse amount: " + amountStr, ex); } } @ImmutableConstructor private  CurrencyAmount(final Currency currency, final double amount); static CurrencyAmount of(final Currency currency, final double amount); static CurrencyAmount of(final String currencyCode, final double amount); @FromString static CurrencyAmount parse(final String amountStr); Currency getCurrency(); double getAmount(); CurrencyAmount plus(final CurrencyAmount amountToAdd); CurrencyAmount plus(final double amountToAdd); CurrencyAmount multipliedBy(final double valueToMultiplyBy); @Override @ToString String toString(); static CurrencyAmount.Meta meta(); @Override CurrencyAmount.Meta metaBean(); @Override Property<R> property(String propertyName); @Override Set<String> propertyNames(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test(dataProvider = "badParse", expectedExceptions = IllegalArgumentException.class) public void test_parse_String_bad(String input) { CurrencyAmount.parse(input); }