KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > monitorenter > util > collections > IComparableProperty


1 /*
2  * IComparableProperty.java allows an instance to be compared by a member.
3  * Copyright (C) Achim Westermann, created on 30.05.2005, 20:14:59
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * If you modify or optimize the code in a useful way please let me know.
20  * Achim.Westermann@gmx.de
21  *
22  */

23 package info.monitorenter.util.collections;
24 /**
25  * An interface that allows implementors to let themselves be compared by a
26  * <code>Comparable</code> {@link java.lang.Number} instance that may be
27  * modified by the comparing classs.
28  * <p>
29  * This allows implementation of {@link java.util.Set} classes that guarantee to
30  * take every new element by shifting the order of the contained operations with
31  * an operation that modifies their comparable <code>Number</code>.
32  * <p>
33  * Note that the methods {@link #getComparableProperty()()} and
34  * {@link #setComparableProperty(Number)} have to be linked to the same member
35  * or source of data (if more advanced) in a way that:
36  * <p>
37  *
38  * <pre>
39  Number number = &lt;initalisation&gt;;
40  aComparableProperty.setComparableProperty(number);
41  <b>1) number.equals(aComparableProperty.getComparableProperty());</b>
42  <b>2) aComparableProperty.getComparableProperty().equals(number);</b>
43  </pre>
44  *
45  * are both true.
46  * </p>
47  *
48  * @author <a HREF="mailto:Achim.Westermann@gmx.de">Achim Westermann </a>
49  *
50  * @version $Revision: 1.1 $
51  *
52  */

53
54 public interface IComparableProperty {
55
56   /**
57    * Returns a {@link Number} this instance wants to be compared by.
58    * <p>
59    *
60    * @return a {@link Number} this instance wants to be compared by.
61    *
62    */

63   public Number JavaDoc getComparableProperty();
64
65   /**
66    * Set the comparable Number.
67    * <p>
68    *
69    * Note that a <code>ComparableProperty</code> has to allow by contract that
70    * it's <code>Number</code> property it lays open to be compared by has to
71    * be modifyable from outside!
72    * <p>
73    *
74    * @param n
75    * the comparable number.
76    *
77    */

78   public void setComparableProperty(Number JavaDoc n);
79
80 }
81
Popular Tags