2023-07-06 10:28:53 +02:00
|
|
|
|
2019-08-09 10:08:34 +02:00
|
|
|
package eu.dnetlib.pace.tree.support;
|
|
|
|
|
2023-07-06 10:28:53 +02:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2019-08-09 10:08:34 +02:00
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
import com.wcohen.ss.AbstractStringDistance;
|
2023-07-06 10:28:53 +02:00
|
|
|
|
2023-07-18 11:38:56 +02:00
|
|
|
public abstract class AbstractSortedComparator extends AbstractListComparator {
|
2019-08-09 10:08:34 +02:00
|
|
|
|
2023-07-06 10:28:53 +02:00
|
|
|
/**
|
|
|
|
* Instantiates a new sorted second string compare algo.
|
|
|
|
*
|
|
|
|
* @param weight
|
|
|
|
* the weight
|
|
|
|
* @param ssalgo
|
|
|
|
* the ssalgo
|
|
|
|
*/
|
|
|
|
protected AbstractSortedComparator(final double weight, final AbstractStringDistance ssalgo) {
|
|
|
|
super(weight, ssalgo);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected AbstractSortedComparator(final Map<String, String> params, final AbstractStringDistance ssalgo) {
|
|
|
|
super(Double.parseDouble(params.get("weight")), ssalgo);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-07-18 11:38:56 +02:00
|
|
|
protected List<String> toList(final Object object) {
|
|
|
|
if (object instanceof List) {
|
|
|
|
List<String> fl = (List<String>) object;
|
|
|
|
List<String> values = Lists.newArrayList(fl);
|
|
|
|
Collections.sort(values);
|
|
|
|
return values;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Lists.newArrayList(object.toString());
|
2023-07-06 10:28:53 +02:00
|
|
|
}
|
2019-08-09 10:08:34 +02:00
|
|
|
}
|