Небольшое изменение бизнес логики

This commit is contained in:
Mark Struchkov 2019-01-21 13:13:56 +03:00
parent 06818e6656
commit ecd3f7a8da

View File

@ -10,6 +10,7 @@ import org.sadtech.autoresponder.submodule.parser.Parser;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.Set; import java.util.Set;
@Log4j @Log4j
@ -56,7 +57,8 @@ public class Autoresponder {
Parser parser = new Parser(); Parser parser = new Parser();
parser.setText(message); parser.setText(message);
parser.parse(); parser.parse();
return nextUnits.stream().filter(nextUnit -> textPercentageMatch(nextUnit, parser.getWords()) >= nextUnit.getMatchThreshold()).max(new UnitPriorityComparator()).get(); Optional<Unit> max = nextUnits.stream().filter(nextUnit -> textPercentageMatch(nextUnit, parser.getWords()) >= nextUnit.getMatchThreshold()).max(new UnitPriorityComparator());
return max.orElse(null);
} else { } else {
return null; return null;
} }