Beispiel #1
0
        public virtual void put(K key, V value)
        {
            if (key == default(K) || value == default(V))
            {
                throw new System.NullReferenceException();
            }

            V previousValue = cache.put(key, value);

            if (previousValue != default(V))
            {
                keys.remove(key);
            }
            keys.add(key);

            if (cache.size() > capacity)
            {
                K lruKey = keys.poll();
                if (lruKey != default(K))
                {
                    cache.remove(lruKey);

                    // remove duplicated keys
                    this.removeAll(lruKey);

                    // queue may not contain any key of a possibly concurrently added entry of the same key in the cache
                    if (cache.containsKey(lruKey))
                    {
                        keys.add(lruKey);
                    }
                }
            }
        }
        public override object build <T1>(Type beanType, BeanBuilder <T1> builder)
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.ConcurrentMap<org.joda.beans.MetaProperty<?>, Object> buffer = ((org.joda.beans.impl.BufferingBeanBuilder<?>) builder).getBuffer();
            ConcurrentMap <MetaProperty <object>, object> buffer = ((BufferingBeanBuilder <object>)builder).Buffer;
            HolidayCalendarId id = builder.get(ID);

            if (buffer.containsKey(HOLIDAYS) && buffer.containsKey(WEEKEND_DAYS))
            {
                ISet <LocalDate> holidays    = builder.get(HOLIDAYS);
                ISet <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));
            }
        }
Beispiel #3
0
        public override object build <T1>(Type beanType, BeanBuilder <T1> builder)
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.joda.beans.impl.BufferingBeanBuilder<?> bld = (org.joda.beans.impl.BufferingBeanBuilder<?>) builder;
            BufferingBeanBuilder <object> bld = (BufferingBeanBuilder <object>)builder;
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.ConcurrentMap<org.joda.beans.MetaProperty<?>, Object> buffer = bld.getBuffer();
            ConcurrentMap <MetaProperty <object>, object> buffer = bld.Buffer;
            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));
            }
        }