001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021 022package org.biojava.bio.program.homologene; 023 024 025import org.biojava.utils.ChangeVetoException; 026 027/** 028 * An abstract implementation of the OrthoPairCollection 029 * interface. Its primary role is to implement the 030 * filter() method.i 031 * 032 * @author David Huen 033 */ 034public abstract class AbstractOrthoPairCollection 035 implements OrthoPairCollection 036{ 037 038 public abstract void add(OrthoPairSet group); 039 040 public abstract boolean contains(OrthoPairSet group); 041 042 public abstract boolean isEmpty(); 043 044 public abstract OrthoPairCollection.Iterator iterator(); 045 046 public OrthoPairCollection filter(OrthoPairSetFilter filters) 047 { 048 OrthoPairCollection results = new SimpleOrthoPairCollection(); 049 050 for (Iterator pairSetsI = iterator(); 051 pairSetsI.hasNext(); ) 052 { 053 OrthoPairSet pairSet = pairSetsI.nextSet(); 054 055 if (filters.accept(pairSet)) { 056 try { 057 results.add(pairSet); 058 } 059 catch (ChangeVetoException cve) { 060 // should be impossible as this group was created by me 061 } 062 } 063 } 064 return results; 065 } 066} 067