package jp.cafebabe.pochi.comparators;

import jp.cafebabe.birthmarks.comparators.Comparator;
import jp.cafebabe.birthmarks.comparators.ComparatorBuilder;
import jp.cafebabe.birthmarks.comparators.ComparatorType;
import jp.cafebabe.birthmarks.comparators.Similarity;
import jp.cafebabe.birthmarks.config.Configuration;
import jp.cafebabe.birthmarks.entities.Birthmark;

import java.util.Set;

public class SimpsonIndexComparator extends IndexComparator {
    private static final ComparatorType thisType = ComparatorType.of("SimpsonIndex");

    public static final class Builder implements ComparatorBuilder {
        @Override
        public ComparatorType type() {
            return thisType;
        }

        @Override
        public Comparator build(Configuration config) {
            return new SimpsonIndexComparator(config);
        }
    }

    public SimpsonIndexComparator(Configuration config){
        super(thisType, config);
    }

    @Override
    protected <T> Similarity calculate(Birthmark<T> left, Birthmark<T> right) {
        if(left.elementCount() == 0 && right.elementCount() == 0)
            return new Similarity(1d);
        else if(left.elementCount() == 0 || right.elementCount() == 0)
            return new Similarity(0d);
        Set<T> intersection = intersect(left, right);
        int denominator = Math.min(left.elementCount(), right.elementCount());
        return new Similarity(1.0 * intersection.size() / denominator);
    }
}

@@ -1048,16 +1048,17 @@
       if
+ 
 (left.el
@@ -1159,16 +1159,17 @@
  else if
+ 
 (left.el
@@ -1251,24 +1251,156 @@
 larity(0d);%0A
+        return calculateImpl(left, right);%0A    %7D%0A%0A    private %3CT%3E Similarity calculateImpl(Birthmark%3CT%3E left, Birthmark%3CT%3E right) %7B%0A
         Set%3C

fix the issue from codebeat