aboutsummaryrefslogtreecommitdiff
path: root/juick-server-jdbc/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server-jdbc/src/main/java')
-rw-r--r--juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java21
1 files changed, 5 insertions, 16 deletions
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java
index 79163d1c..9b89bca3 100644
--- a/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java
+++ b/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java
@@ -41,9 +41,11 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Created by aalexeev on 11/13/16.
@@ -108,22 +110,9 @@ public class TagServiceImpl extends BaseJdbcService implements TagService {
}
@Override
- public List<Tag> getTags(final String[] tags, final boolean autoCreate) {
- if (ArrayUtils.isEmpty(tags))
- return Collections.emptyList();
-
- List<Tag> ret = new ArrayList<>();
-
- for (String tag : tags) {
- if (!tag.isEmpty()) {
- Tag t = getTag(tag, autoCreate);
-
- if (t != null)
- ret.add(t);
- }
- }
-
- return ret.stream().distinct().collect(Collectors.toList());
+ public List<Tag> getTags(Stream<String> tags, final boolean autoCreate) {
+ return tags.filter(StringUtils::isNotBlank).map(tag -> getTag(tag, autoCreate)).filter(Objects::nonNull).distinct()
+ .collect(Collectors.toList());
}
@Transactional(readOnly = true)