1 17 package org.apache.excalibur.event.impl; 18 19 import org.apache.excalibur.event.EnqueuePredicate; 20 import org.apache.excalibur.event.Sink; 21 22 28 public final class ThresholdEnqueuePredicate implements EnqueuePredicate 29 { 30 private final int m_threshold; 31 32 37 public ThresholdEnqueuePredicate(int limit) 38 { 39 m_threshold = limit; 40 } 41 42 46 public boolean accept(Object element, Sink modifyingSink) 47 { 48 if ( m_threshold <=0 ) return true; 49 50 return (modifyingSink.size() + 1) < m_threshold; 51 } 52 53 57 public boolean accept(Object [] elements, Sink modifyingSink) 58 { 59 if ( m_threshold <=0 ) return true; 60 61 return (modifyingSink.size() + elements.length) < m_threshold; 62 } 63 } 64 | Popular Tags |