source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/types/selectors/modifiedselector/EqualComparator.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 1.7 KB
Line 
1/*
2 * Copyright 2003-2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.apache.tools.ant.types.selectors.modifiedselector;
19
20
21import java.util.Comparator;
22
23
24/**
25 * Simple implementation of Comparator for use in CacheSelector.
26 * compare() returns '0' (should not be selected) if both parameter
27 * are equal otherwise '1' (should be selected).
28 *
29 * @version 2003-09-13
30 * @since Ant 1.6
31 */
32public class EqualComparator implements Comparator {
33
34 /**
35 * Implements Comparator.compare().
36 * @param o1 the first object
37 * @param o2 the second object
38 * @return 0, if both are equal, otherwise 1
39 */
40 public int compare(Object o1, Object o2) {
41 if (o1 == null) {
42 if (o2 == null) {
43 return 1;
44 } else {
45 return 0;
46 }
47 } else {
48 return (o1.equals(o2)) ? 0 : 1;
49 }
50 }
51
52 /**
53 * Override Object.toString().
54 * @return information about this comparator
55 */
56 public String toString() {
57 return "EqualComparator";
58 }
59}
Note: See TracBrowser for help on using the repository browser.