1 | package org.apache.tools.ant.types.resources.comparators;↵ | | 1 | package org.apache.tools.ant.types.resources.comparators;↵
|
|
2 | import org.apache.tools.ant.types.Resource;↵ | | 2 | import org.apache.tools.ant.types.Resource;↵
|
|
3 | /**↵ | | 3 | /**↵
|
4 | * Compares Resources by existence. Not existing is "less than" existing↵ | | 4 | * Compares Resources by is-directory status. As a container↵
|
5 | .↵ | | 5 | * of files, a directory is deemed "greater" than a file.↵
|
6 | * @since Ant 1.7↵ | | 6 | * @since Ant 1.7↵
|
7 | */↵ | | 7 | */↵
|
8 | public class Exists extends ResourceComparator {↵ | | 8 | public class Type extends ResourceComparator {↵
|
|
9 | /**↵ | | 9 | /**↵
|
10 | * Compare two Resources.↵ | | 10 | * Compare two Resources.↵
|
11 | * @param foo the first Resource.↵ | | 11 | * @param foo the first Resource.↵
|
12 | * @param bar the second Resource.↵ | | 12 | * @param bar the second Resource.↵
|
13 | * @return a negative integer, zero, or a positive integer as the first↵ | | 13 | * @return a negative integer, zero, or a positive integer as the first↵
|
14 | * argument is less than, equal to, or greater than the second.↵ | | 14 | * argument is less than, equal to, or greater than the second.↵
|
15 | */↵ | | 15 | */↵
|
16 | protected int resourceCompare(Resource foo, Resource bar) {↵ | | 16 | protected int resourceCompare(Resource foo, Resource bar) {↵
|
17 | boolean f = foo.isExists();↵ | | 17 | boolean f = foo.isDirectory();↵
|
18 | if (f == bar.isExists()) {↵ | | 18 | if (f == bar.isDirectory()) {↵
|
19 | return 0;↵ | | 19 | return 0;↵
|
20 | }↵ | | 20 | }↵
|
21 | return f ? 1 : -1;↵ | | 21 | return f ? 1 : -1;↵
|
22 | }↵ | | 22 | }↵
|
|
23 | } | | 23 | }
|