src/core/net/sf/basedb/util/collections/CollectionTransformer.java

Code
Comments
Other
Rev Date Author Line
4712 19 Dec 08 nicklas 1 /**
4712 19 Dec 08 nicklas 2   $Id$
4712 19 Dec 08 nicklas 3
4712 19 Dec 08 nicklas 4   Copyright (C) 2008 Nicklas Nordborg
4712 19 Dec 08 nicklas 5
4712 19 Dec 08 nicklas 6   This file is part of BASE - BioArray Software Environment.
4712 19 Dec 08 nicklas 7   Available at http://base.thep.lu.se/
4712 19 Dec 08 nicklas 8
4712 19 Dec 08 nicklas 9   BASE is free software; you can redistribute it and/or
4712 19 Dec 08 nicklas 10   modify it under the terms of the GNU General Public License
4712 19 Dec 08 nicklas 11   as published by the Free Software Foundation; either version 3
4712 19 Dec 08 nicklas 12   of the License, or (at your option) any later version.
4712 19 Dec 08 nicklas 13
4712 19 Dec 08 nicklas 14   BASE is distributed in the hope that it will be useful,
4712 19 Dec 08 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
4712 19 Dec 08 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4712 19 Dec 08 nicklas 17   GNU General Public License for more details.
4712 19 Dec 08 nicklas 18
4712 19 Dec 08 nicklas 19   You should have received a copy of the GNU General Public License
4712 19 Dec 08 nicklas 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
4712 19 Dec 08 nicklas 21 */
4712 19 Dec 08 nicklas 22 package net.sf.basedb.util.collections;
4712 19 Dec 08 nicklas 23
4712 19 Dec 08 nicklas 24 import java.util.Collection;
4712 19 Dec 08 nicklas 25
4712 19 Dec 08 nicklas 26
4712 19 Dec 08 nicklas 27 /**
4712 19 Dec 08 nicklas 28   Allows a collection to be transformed by applying some operation to it. 
4712 19 Dec 08 nicklas 29   The transformed items should be added to the destination collection. The
4712 19 Dec 08 nicklas 30   source collection is not allowed to be modified. Client applications 
4712 19 Dec 08 nicklas 31   should NOT use the same collection as both source and destination since that
4712 19 Dec 08 nicklas 32   may interfere with iterators on the source collection. 
4723 13 Jan 09 nicklas 33   The destination collection may contain elements of the same or a different type
4712 19 Dec 08 nicklas 34   as the source collection.
4712 19 Dec 08 nicklas 35
4712 19 Dec 08 nicklas 36   @author Nicklas
4712 19 Dec 08 nicklas 37   @version 2.10
4712 19 Dec 08 nicklas 38   @base.modified $Date$
4712 19 Dec 08 nicklas 39   @param <D> The element type contained in the destination collection
4712 19 Dec 08 nicklas 40   @param <S> The element type of the source collection
4712 19 Dec 08 nicklas 41 */
4712 19 Dec 08 nicklas 42 public interface CollectionTransformer<S, D>
4712 19 Dec 08 nicklas 43 {
4712 19 Dec 08 nicklas 44   /**
4712 19 Dec 08 nicklas 45     Transform the source collection and store the changes in the
4712 19 Dec 08 nicklas 46     destination collection.
4712 19 Dec 08 nicklas 47     
4712 19 Dec 08 nicklas 48     @param source The source collection
4712 19 Dec 08 nicklas 49     @param destination The destination collection
4712 19 Dec 08 nicklas 50     @return The number of elements affected in the destination collection. Note!
4712 19 Dec 08 nicklas 51       This value may have a different meaning depending on the implementor. For
4712 19 Dec 08 nicklas 52       example, some implementor may add elements while other implementor may 
4723 13 Jan 09 nicklas 53       remove elements. A return value of 0 should always indicate that no modifications 
4712 19 Dec 08 nicklas 54       has been made to the destination collection.
4712 19 Dec 08 nicklas 55   */
4712 19 Dec 08 nicklas 56   public int transform(Collection<? extends S> source, Collection<? super D> destination);
4712 19 Dec 08 nicklas 57   
4712 19 Dec 08 nicklas 58 }