1
0
mirror of https://github.com/mitb-archive/filebot synced 2025-03-10 06:20:27 -04:00
filebot/source/net/filebot/similarity/FileSizeMetric.java
2014-04-19 06:30:29 +00:00

34 lines
514 B
Java

package net.filebot.similarity;
import java.io.File;
public class FileSizeMetric implements SimilarityMetric {
@Override
public float getSimilarity(Object o1, Object o2) {
long l1 = getLength(o1);
if (l1 < 0)
return 0;
long l2 = getLength(o2);
if (l2 < 0)
return 0;
// objects have the same non-negative length
return l1 == l2 ? 1 : -1;
}
protected long getLength(Object object) {
if (object instanceof File) {
return ((File) object).length();
}
return -1;
}
}