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:
19: package org.apache.tools.ant.types.selectors.modifiedselector;
20:
21: import java.util.Comparator;
22:
23: /**
24: * Simple implementation of Comparator for use in CacheSelector.
25: * compare() returns '0' (should not be selected) if both parameter
26: * are equal otherwise '1' (should be selected).
27: *
28: * @version 2003-09-13
29: * @since Ant 1.6
30: */
31: public class EqualComparator implements Comparator {
32:
33: /**
34: * Implements Comparator.compare().
35: * @param o1 the first object
36: * @param o2 the second object
37: * @return 0, if both are equal, otherwise 1
38: */
39: public int compare(Object o1, Object o2) {
40: if (o1 == null) {
41: if (o2 == null) {
42: return 1;
43: }
44: return 0;
45: }
46: return (o1.equals(o2)) ? 0 : 1;
47: }
48:
49: /**
50: * Override Object.toString().
51: * @return information about this comparator
52: */
53: public String toString() {
54: return "EqualComparator";
55: }
56: }
|