w ͦͷιϑτΣΞͷ֓೦Λཧղ͍ͯ͠ΔҰ෦ͷਓ ͍ͨ ͍ͯ։ൃऀ ͚ͨͪͩͱ͍͏ঢ়گΛͳ͘͢ɻ w υϝΠϯΤΩεύʔτͱ։ൃऀɺιϑτΣΞͦͷ ͷͱͷؒͰɺҰͷ௨༁Λෆཁͱ͢Δɻ w ઃܭ͕ίʔυͰ͋Γɺίʔυ͕ઃܭͰ͋Δͱ͍͏ঢ় گΛ࡞Γग़͢ɻ Θ͔ΔʂυϝΠϯۦಈઃܭʙͪ͜ΌΜͷେݥʙ͔ΒҾ༻
static BankAccount of(Long id, List<BankAccountEvent> events) { if (getTotalAmountByEvents(events).isLessThan(Money.zero())) { throw new IllegalArgumentException("total amount is less than zero!"); } return new BankAccount(id, events); } // தུ } ޱ࠲ͷߴθϩະຬʹͳͬͯͳΒͳ͍
money2 = new Money(); money2.setCurrency(Currency.getInstance("JPY")); money2.setAmount(BigDecimal.valueOf(10000)); BigDecimal total = money1.getAmount().add(money2.getAmount()); Money result = new Money(); result.setCurrency(money1.getCurrency()); result.setAmount(total); ؒҧ͍Ͱͳ͍͕ɺΘ͔Γʹ͍͘ɻ ΦϒδΣΫτࢦͷྑ͕͞ࡴ͞ΕΔ