| 1 | |
package org.webslinger.commons.vfs; |
| 2 | |
|
| 3 | |
import java.util.Collections; |
| 4 | |
import java.util.HashSet; |
| 5 | |
import java.util.Set; |
| 6 | |
|
| 7 | |
import org.apache.commons.vfs.FileObject; |
| 8 | |
|
| 9 | |
public final class FileSet { |
| 10 | |
public final Set<FileSystemAndNameKey> contentFiles; |
| 11 | |
public final Set<FileSystemAndNameKey> existantFiles; |
| 12 | |
|
| 13 | |
private static final Set<FileSystemAndNameKey> makeSet(FileObject[] files) { |
| 14 | 0 | Set<FileSystemAndNameKey> set = new HashSet<FileSystemAndNameKey>(files.length); |
| 15 | 0 | for (FileObject file: files) { |
| 16 | 0 | set.add(new FileSystemAndNameKey(file)); |
| 17 | |
} |
| 18 | 0 | return Collections.unmodifiableSet(set); |
| 19 | |
} |
| 20 | |
|
| 21 | 0 | protected FileSet(FileObject[] contentFiles, FileObject[] existantFiles) { |
| 22 | 0 | this.contentFiles = makeSet(contentFiles); |
| 23 | 0 | this.existantFiles = makeSet(existantFiles); |
| 24 | 0 | } |
| 25 | |
|
| 26 | |
public boolean equals(Object o) { |
| 27 | 0 | if (!(o instanceof FileSet)) return false; |
| 28 | 0 | FileSet other = (FileSet) o; |
| 29 | 0 | return contentFiles.equals(other.contentFiles) && existantFiles.equals(other.existantFiles); |
| 30 | |
} |
| 31 | |
|
| 32 | |
public int hashCode() { |
| 33 | 0 | return contentFiles.hashCode() ^ existantFiles.hashCode(); |
| 34 | |
} |
| 35 | |
} |