diff options
Diffstat (limited to 'juick-server-jdbc/src')
-rw-r--r-- | juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java | 8 |
1 files changed, 4 insertions, 4 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 d7800390..524ad32d 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 @@ -20,6 +20,7 @@ package com.juick.service; import com.juick.Tag; import com.juick.User; import com.juick.server.helpers.TagStats; +import com.juick.util.StreamUtils; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.jdbc.core.RowMapper; @@ -210,10 +211,9 @@ public class TagServiceImpl extends BaseJdbcService implements TagService { @Override public List<Tag> fromString(final String txt) { String firstLine = txt.split("\\n", 2)[0]; - List<String> firstWords = Arrays.asList(firstLine.split("\\ ")); - int nonTagIndex = IntStream.range(0, firstWords.size()) - .filter(i -> !firstWords.get(i).startsWith("*")).findFirst().orElse(firstWords.size()); - return firstWords.subList(0, nonTagIndex).stream().map(t -> getTag(t.substring(1), true)) + return StreamUtils.takeWhile(Arrays.stream(firstLine.split("\\ ")), + t -> !t.equals("*") && t.startsWith("*")) + .map(t -> getTag(t.substring(1), true)) .collect(Collectors.toList()); } |