@Override public Object build(Class<?> beanType, BeanBuilder<?> builder) { ConcurrentMap<MetaProperty<?>, Object> buffer = ((BufferingBeanBuilder<?>) builder).getBuffer(); HolidayCalendarId id = builder.get(ID); if (buffer.containsKey(HOLIDAYS) && buffer.containsKey(WEEKEND_DAYS)) { Set<LocalDate> holidays = builder.get(HOLIDAYS); Set<DayOfWeek> weekendDays = builder.get(WEEKEND_DAYS); return ImmutableHolidayCalendar.of(id, holidays, weekendDays); } else { int weekends = builder.get(WEEKENDS); int startYear = builder.get(START_YEAR); int[] lookup = builder.get(LOOKUP); return new ImmutableHolidayCalendar(id, weekends, startYear, lookup, false); } }
@Override public Object build(Class<?> beanType, BeanBuilder<?> builder) { BufferingBeanBuilder<?> bld = (BufferingBeanBuilder<?>) builder; ConcurrentMap<MetaProperty<?>, Object> buffer = bld.getBuffer(); BusinessDayAdjustment bda = (BusinessDayAdjustment) buffer.getOrDefault(PAYMENT_ADJUSTMENT_DATE, null); if (buffer.containsKey(BASE_CURRENCY_AMOUNT) && buffer.containsKey(COUNTER_CURRENCY_AMOUNT) && buffer.containsKey(PAYMENT_DATE)) { CurrencyAmount baseAmount = (CurrencyAmount) builder.get(BASE_CURRENCY_AMOUNT); CurrencyAmount counterAmount = (CurrencyAmount) builder.get(COUNTER_CURRENCY_AMOUNT); LocalDate paymentDate = (LocalDate) builder.get(PAYMENT_DATE); return bda != null ? FxSingle.of(baseAmount, counterAmount, paymentDate, bda) : FxSingle.of(baseAmount, counterAmount, paymentDate); } else { Payment basePayment = (Payment) buffer.get(BASE_CURRENCY_PAYMENT); Payment counterPayment = (Payment) buffer.get(COUNTER_CURRENCY_PAYMENT); return bda != null ? FxSingle.of(basePayment, counterPayment, bda) : FxSingle.of(basePayment, counterPayment); } }