Money implements ValueObject { public static Money valueOf(Currency currency, Integer value) { if (currency == null || value == null) { return null; } else { return new Money(currency, value); } } @JsonCreator  Money(@NonNull @JsonProperty("currency") Currency currency, @JsonProperty("amount") int amount);  Money(@NonNull Currency currency, double amount); static Money valueOf(Currency currency, Integer value); @NonNull Money add(@NonNull Money augend); @NonNull Money subtract(@NonNull Money subtrahend); @NonNull Money multiply(int multiplicand); @NonNull Currency currency(); int fixedPointAmount(); double doubleAmount(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void valueOf_nullCurrency_nullReturned() { assertThat(Money.valueOf(null, 123)).isNull(); }
@Test public void valueOf_nullValue_nullReturned() { assertThat(Money.valueOf(Currency.SEK, null)).isNull(); }
@Test public void valueOf_nonNull_moneyCreated() { assertThat(Money.valueOf(Currency.SEK, 12300)).isEqualTo(new Money(Currency.SEK, 123.00)); }