From dbd61ce80c9bd8459b19feebca8c176b404ec398 Mon Sep 17 00:00:00 2001 From: anastasia shulga Date: Tue, 16 Apr 2019 07:55:37 +0000 Subject: [PATCH] Update TagService.java --- src/main/java/ru/ulstu/tags/service/TagService.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/ulstu/tags/service/TagService.java b/src/main/java/ru/ulstu/tags/service/TagService.java index 681a506..e68c683 100644 --- a/src/main/java/ru/ulstu/tags/service/TagService.java +++ b/src/main/java/ru/ulstu/tags/service/TagService.java @@ -23,8 +23,16 @@ public class TagService { return tags .stream() .map(tag -> { - return tag.getId() != null ? getExistById(tag) : - isExistByName(tag.getTagName()) != null ? isExistByName(tag.getTagName()) : create(tag); + if(tag.getId() != null){ + return getExistById(tag); + }else { + Tag existTag = isExistByName(tag.getTagName()); + if(existTag != null){ + return existTag; + }else{ + return create(tag); + } + } }).collect(Collectors.toList()); }