1
0
mirror of https://github.com/mitb-archive/filebot synced 2025-01-13 06:48:04 -05:00
filebot/source/net/filebot/similarity/StringEqualsMetric.java
2014-04-19 06:30:29 +00:00

24 lines
450 B
Java

package net.filebot.similarity;
public class StringEqualsMetric implements SimilarityMetric {
@Override
public float getSimilarity(Object o1, Object o2) {
if (o1 == null || o2 == null)
return 0;
String s1 = normalize(o1);
String s2 = normalize(o2);
if (s1.isEmpty() || s2.isEmpty())
return 0;
return s1.equals(s2) ? 1 : 0;
}
protected String normalize(Object object) {
return object.toString().trim().toLowerCase();
}
}