01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package java.util;
19:
20: /**
21: * Comparator is used to compare two objects to determine their ordering in
22: * respect to each other.
23: *
24: * @since 1.2
25: */
26: public interface Comparator<T> {
27: /**
28: * Compare the two objects to determine the relative ordering.
29: *
30: * @param object1
31: * an Object to compare
32: * @param object2
33: * an Object to compare
34: * @return an int < 0 if object1 is less than object2, 0 if they are equal,
35: * and > 0 if object1 is greater
36: *
37: * @exception ClassCastException
38: * when objects are not the correct type
39: */
40: public int compare(T object1, T object2);
41:
42: /**
43: * Compares the argument to the receiver, and answers true if they represent
44: * the <em>same</em> object using a class specific comparison.
45: *
46: * @param object
47: * Object the object to compare with this object.
48: * @return boolean <code>true</code> if the object is the same as this
49: * object <code>false</code> if it is different from this object.
50: * @see Object#hashCode
51: */
52: public boolean equals(Object object);
53: }
|