Esempio n. 1
0
        public void weigher_withCustom(Builder <int, byte[]> builder)
        {
            builder.Weigher(Weighers.ByteArray());
            IEntryWeigher <int, byte[]> weigher       = ((BoundedEntryWeigher <int, byte[]>)builder.Build().weigher).weigher;
            IWeigher <byte[]>           customWeigher = ((EntryWeigherView <int, byte[]>)weigher).weigher;

            Assert.That(customWeigher, Is.SameAs((Object)Weighers.ByteArray()));
        }
Esempio n. 2
0
 internal EntryWeigherView(IWeigher <V> weigher)
 {
     if (weigher == null)
     {
         throw new ArgumentNullException();
     }
     this.weigher = weigher;
 }
Esempio n. 3
0
        public BoundedWeigher(IWeigher <K, V> @delegate)
        {
            if (EqualityComparer <IWeigher <K, V> > .Default.Equals(@delegate, default(IWeigher <K, V>)))
            {
                throw new ArgumentNullException("delegate", "delegate cannot be null.");
            }

            this.@delegate = @delegate;
        }
Esempio n. 4
0
        public Caffeine <K, V> SpecifyWeigher(IWeigher <K, V> weigher)
        {
            if (weigher == null)
            {
                throw new ArgumentNullException("weigher", "weigher cannot be null.");
            }

            if (this.weigher != null)
            {
                throw new InvalidOperationException("weigher was already set.");
            }

            if (strictParsing && maximumSize != UNSET_INT)
            {
                throw new InvalidOperationException("weigher cannot be combined with maximum size.");
            }

            this.weigher = weigher;

            return(this);
        }
Esempio n. 5
0
 public AsyncWeigher(IWeigher <K, V> @delegate)
 {
     this.@delegate = @delegate;
 }
Esempio n. 6
0
 public static IEntryWeigher <K, V> AsEntryWeigher <K, V>(IWeigher <V> weigher)
 {
     // todo: old code (weigher == singleton()) ? Weighers.entrySingleton<K, V>() :
     return(new EntryWeigherView <K, V>(weigher));
 }