in commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemOptions.java [139:179]
public int compareTo(final FileSystemOptions other) {
if (this == other) {
// the same instance
return 0;
}
final int propsSz = options == null ? 0 : options.size();
final int propsFkSz = other.options == null ? 0 : other.options.size();
if (propsSz < propsFkSz) {
return -1;
}
if (propsSz > propsFkSz) {
return 1;
}
if (propsSz == 0) {
// props empty
return 0;
}
// ensure proper sequence of options
final SortedMap<FileSystemOptionKey, Object> myOptions = options instanceof SortedMap
? (SortedMap<FileSystemOptionKey, Object>) options
: new TreeMap<>(options);
final SortedMap<FileSystemOptionKey, Object> theirOptions = other.options instanceof SortedMap
? (SortedMap<FileSystemOptionKey, Object>) other.options
: new TreeMap<>(other.options);
final Iterator<FileSystemOptionKey> optKeysIter = myOptions.keySet().iterator();
final Iterator<FileSystemOptionKey> otherKeysIter = theirOptions.keySet().iterator();
while (optKeysIter.hasNext()) {
final int comp = optKeysIter.next().compareTo(otherKeysIter.next());
if (comp != 0) {
return comp;
}
}
final int hash = Arrays.deepHashCode(myOptions.values().toArray());
final int hashFk = Arrays.deepHashCode(theirOptions.values().toArray());
return Integer.compare(hash, hashFk);
// TODO: compare Entry by Entry ??
}