001 package listFW.visitor;
002
003 import listFW.*;
004 /**
005 * Sums a list of Numbers, but only the integer part of the values.
006 * A test to see if the methods could be declared to return a subclass
007 * of the paramaterized type.
008 * @author Mathias Ricken - Copyright 2008 - All rights reserved.
009 */
010 public class SumIntValList implements IListAlgo<Number,Number,Object> {
011
012 public Integer emptyCase(IMTList<? extends Number> host, Object ... inp) {
013 return 0;
014 }
015 public Integer nonEmptyCase(INEList<? extends Number> host, Object ... inp) {
016 return host.getFirst().intValue() + host.getRest().execute(this).intValue();
017 }
018 }