KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgrapht > experimental > equivalence > EquivalenceComparatorChain


1 /* ==========================================
2  * JGraphT : a free Java graph-theory library
3  * ==========================================
4  *
5  * Project Info: http://jgrapht.sourceforge.net/
6  * Project Creator: Barak Naveh (http://sourceforge.net/users/barak_naveh)
7  *
8  * (C) Copyright 2003-2006, by Barak Naveh and Contributors.
9  *
10  * This library is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or
13  * (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this library; if not, write to the Free Software Foundation,
22  * Inc.,
23  * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
24  */

25 /* -----------------
26  * EquivalenceComparatorChain.java
27  * -----------------
28  * (C) Copyright 2005-2006, by Assaf Lehr and Contributors.
29  *
30  * Original Author: Assaf Lehr
31  * Contributor(s): -
32  *
33  * $Id: EquivalenceComparatorChain.java 504 2006-07-03 02:37:26Z perfecthash $
34  *
35  * Changes
36  * -------
37  */

38 package org.jgrapht.experimental.equivalence;
39
40 /**
41  * A container of comparators, which are tested in a chain until the first
42  * result can be supplied. It implements the EquivalenceComparator, so chains
43  * can include other chains. The first check will use the current comparator and
44  * not the next one. So, make sure to use the one which has better performance
45  * first. (This class follows the "Composite" design-pattern).
46  *
47  * @param <E> the type of the elements in the set
48  * @param <C> the type of the context the element is compared against, e.g. a
49  * Graph
50  *
51  * @author Assaf
52  * @since Jul 22, 2005
53  */

54 public interface EquivalenceComparatorChain<E, C>
55     extends EquivalenceComparator<E, C>
56 {
57
58     //~ Methods ---------------------------------------------------------------
59

60     /**
61      * Adds a comparator which will also test equivalence. For
62      * equivalenceCompare(), the return value is a logical AND of the two
63      * comparators. The first check will use the first comparator before the
64      * next one. Make sure to put the one which has better performance first.
65      * For equivalenceHashcode(), the resulting hashes will be rehashed
66      * together. This method may be used multiple times to create a long "chain"
67      * of comparators.
68      */

69     public void appendComparator(EquivalenceComparator comparatorAfter);
70 }
71
Popular Tags