class SuccessCountsQueuePrecedencePolicy extends BaseQueuePrecedencePolicy {
    private static final long serialVersionUID = -4469760728466350850L;

// TODO: determine why this doesn't work
//
//    /** comma-separated list of success-counts at which precedence is bumped*/
//    final public static Key<List<Integer>> INCREMENT_COUNTS = 
//        Key.make((List<Integer>)Arrays.asList(new Integer[] {100}));
//
//    /**
//     * @param wq
//     * @return
//     */
//    protected int calculatePrecedence(WorkQueue wq) {
//        // FIXME: it's inefficient to do this every time; optimizing 
//        // should be possible via more sophisticated custom PrecedenceProvider
//        int precedence = wq.get(this,BASE_PRECEDENCE) - 1;
//        Iterator<Integer> iter = wq.get(this,INCREMENT_COUNTS).iterator();
//        int increment = iter.next(); 
//        long successes = wq.getSubstats().getFetchSuccesses();
//        while(successes>0) {
//            successes -= increment;
//            precedence++;
//            increment = iter.hasNext() ? iter.next() : increment; 
//        }
//        return precedence;
//    }

    {
        setIncrementCounts("100,1000");
    }
    public String getIncrementCounts() {
        return (String) kp.get("incrementCounts");
    }
    /** comma-separated list of success-counts at which precedence is bumped*/
    public void setIncrementCounts(String counts) {
        kp.put("incrementCounts",counts);
    }

    /* (non-Javadoc)
     * @see org.archive.crawler.frontier.QueuePrecedencePolicy#queueReevaluate(org.archive.crawler.frontier.WorkQueue)
     */
    @SuppressWarnings("unchecked")
    @Override
    protected int calculatePrecedence(WorkQueue wq) {<FILL_FUNCTION_BODY>}
}

        // FIXME: it's ridiculously inefficient to do this every time, 
        // and optimizing will probably require inserting stateful policy 
        // helper object into WorkQueue -- expected when URI-precedence is
        // also supported
        int precedence = getBasePrecedence() - 1;
        Collection<Integer> increments = CollectionUtils.collect(
                Arrays.asList(getIncrementCounts().split(",")),
                new Transformer() {
                    public Object transform(final Object string) {
                        return Integer.parseInt((String)string);
                    }});
        Iterator<Integer> iter = increments.iterator();
        int increment = iter.next(); 
        long successes = wq.getSubstats().getFetchSuccesses();
        while(successes>=0) {
            successes -= increment;
            precedence++;
            increment = iter.hasNext() ? iter.next() : increment; 
        }
        return precedence;
    
<methods>public non-sealed void <init>() ,public int getBasePrecedence() ,public org.archive.spring.KeyedProperties getKeyedProperties() ,public void queueCreated(org.archive.crawler.frontier.WorkQueue) ,public void queueReevaluate(org.archive.crawler.frontier.WorkQueue) ,public void setBasePrecedence(int) <variables>protected org.archive.spring.KeyedProperties kp,private static final long serialVersionUID