diff options
Diffstat (limited to 'src/main/java/com/juick/service')
3 files changed, 7 insertions, 10 deletions
diff --git a/src/main/java/com/juick/service/MessagesService.java b/src/main/java/com/juick/service/MessagesService.java index 362501b5..fb2b3d95 100644 --- a/src/main/java/com/juick/service/MessagesService.java +++ b/src/main/java/com/juick/service/MessagesService.java @@ -23,10 +23,7 @@ import com.juick.User; import com.juick.model.ResponseReply; import java.net.URI; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * Created by aalexeev on 11/13/16. @@ -63,7 +60,7 @@ public interface MessagesService { int getMessagePrivacy(int mid); - com.juick.Message getMessage(int mid); + Optional<Message> getMessage(int mid); com.juick.Message getReply(int mid, int rid); diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java index efe480c0..145d42c3 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -343,7 +343,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ @Transactional(readOnly = true) @Override - public com.juick.Message getMessage(final int mid) { + public Optional<com.juick.Message> getMessage(final int mid) { List<com.juick.Message> list = getJdbcTemplate().query( "SELECT messages.message_id as mid, 0 as rid, 0 as replyto, " @@ -369,9 +369,9 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ Map<Integer, Set<Reaction>> reactionStats = updateReactionsFor(Collections.singletonList(mid)); message.setReactions(reactionStats.get(message.getMid())); message.setEntities(MessageUtils.getEntities(message)); - return message; + return Optional.of(message); } - return null; + return Optional.empty(); } @Transactional(readOnly = true) diff --git a/src/main/java/com/juick/service/component/MessageReadEvent.java b/src/main/java/com/juick/service/component/MessageReadEvent.java index b070c8cb..b2af4a08 100644 --- a/src/main/java/com/juick/service/component/MessageReadEvent.java +++ b/src/main/java/com/juick/service/component/MessageReadEvent.java @@ -4,7 +4,7 @@ import com.juick.Message; import com.juick.User; import org.springframework.context.ApplicationEvent; -import java.util.List; +import javax.annotation.Nonnull; public class MessageReadEvent extends ApplicationEvent { private User user; @@ -14,7 +14,7 @@ public class MessageReadEvent extends ApplicationEvent { * * @param source the object on which the event initially occurred (never {@code null}) */ - public MessageReadEvent(Object source, User user, Message message) { + public MessageReadEvent(Object source, @Nonnull User user, Message message) { super(source); this.user = user; this.message = message; |