|
18 | 18 | package ru.mystamps.web.service;
|
19 | 19 |
|
20 | 20 | import java.math.BigDecimal;
|
| 21 | +import java.util.Arrays; |
21 | 22 | import java.util.Collections;
|
22 |
| -import java.util.HashSet; |
23 | 23 | import java.util.List;
|
24 | 24 | import java.util.Set;
|
25 | 25 | import java.util.regex.Matcher;
|
26 | 26 | import java.util.regex.Pattern;
|
| 27 | +import java.util.stream.Collectors; |
27 | 28 |
|
28 | 29 | import org.apache.commons.lang3.StringUtils;
|
29 | 30 |
|
@@ -89,8 +90,9 @@ protected List<Integer> extractCategory(String fragment) {
|
89 | 90 | log.debug("Determining category from a fragment: '{}'", fragment);
|
90 | 91 |
|
91 | 92 | String[] candidates = StringUtils.split(fragment, "\n\t ,");
|
92 |
| - Set<String> uniqueCandidates = new HashSet<>(); |
93 |
| - Collections.addAll(uniqueCandidates, candidates); |
| 93 | + Set<String> uniqueCandidates = Arrays.stream(candidates) |
| 94 | + .distinct() |
| 95 | + .collect(Collectors.toSet()); |
94 | 96 |
|
95 | 97 | log.debug("Possible candidates: {}", uniqueCandidates);
|
96 | 98 |
|
@@ -122,8 +124,9 @@ protected List<Integer> extractCountry(String fragment) {
|
122 | 124 | log.debug("Determining country from a fragment: '{}'", fragment);
|
123 | 125 |
|
124 | 126 | String[] candidates = StringUtils.split(fragment, "\n\t ,");
|
125 |
| - Set<String> uniqueCandidates = new HashSet<>(); |
126 |
| - Collections.addAll(uniqueCandidates, candidates); |
| 127 | + Set<String> uniqueCandidates = Arrays.stream(candidates) |
| 128 | + .distinct() |
| 129 | + .collect(Collectors.toSet()); |
127 | 130 |
|
128 | 131 | log.debug("Possible candidates: {}", uniqueCandidates);
|
129 | 132 |
|
|
0 commit comments