2023-07-06 10:28:53 +02:00
|
|
|
|
2019-08-09 15:41:49 +02:00
|
|
|
package eu.dnetlib.pace.tree;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2019-10-29 16:38:42 +01:00
|
|
|
import eu.dnetlib.pace.config.Config;
|
2023-07-18 11:38:56 +02:00
|
|
|
import eu.dnetlib.pace.tree.support.AbstractListComparator;
|
2019-08-09 15:41:49 +02:00
|
|
|
import eu.dnetlib.pace.tree.support.ComparatorClass;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the number of values in the fields is the same.
|
|
|
|
*
|
|
|
|
* @author claudio
|
|
|
|
*/
|
|
|
|
@ComparatorClass("sizeMatch")
|
2023-07-18 11:38:56 +02:00
|
|
|
public class SizeMatch extends AbstractListComparator {
|
2019-08-09 15:41:49 +02:00
|
|
|
|
2023-07-06 10:28:53 +02:00
|
|
|
/**
|
|
|
|
* Instantiates a new size match.
|
|
|
|
*
|
|
|
|
* @param params
|
|
|
|
* the parameters
|
|
|
|
*/
|
|
|
|
public SizeMatch(final Map<String, String> params) {
|
|
|
|
super(params);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-07-18 11:38:56 +02:00
|
|
|
public double compare(final List<String> a, final List<String> b, final Config conf) {
|
2023-07-06 10:28:53 +02:00
|
|
|
|
|
|
|
if (a.isEmpty() || b.isEmpty())
|
2023-07-18 11:38:56 +02:00
|
|
|
return -1.0;
|
2023-07-06 10:28:53 +02:00
|
|
|
|
2023-07-18 11:38:56 +02:00
|
|
|
return a.size() == b.size() ? 1.0 : 0.0;
|
2023-07-06 10:28:53 +02:00
|
|
|
}
|
2019-08-09 15:41:49 +02:00
|
|
|
|
|
|
|
}
|