diff --git a/udacity-jwdnd-c1-l5-final-review-solution-master/src/main/java/com/udacity/jwdnd/c1/review/service/MessageService.java b/udacity-jwdnd-c1-l5-final-review-solution-master/src/main/java/com/udacity/jwdnd/c1/review/service/MessageService.java index fee391a..fe9b44a 100644 --- a/udacity-jwdnd-c1-l5-final-review-solution-master/src/main/java/com/udacity/jwdnd/c1/review/service/MessageService.java +++ b/udacity-jwdnd-c1-l5-final-review-solution-master/src/main/java/com/udacity/jwdnd/c1/review/service/MessageService.java @@ -5,13 +5,13 @@ import com.udacity.jwdnd.c1.review.model.ChatMessage; import org.springframework.stereotype.Service; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import java.util.List; @Service public class MessageService { - private MessageMapper messageMapper; + private final MessageMapper messageMapper; public MessageService(MessageMapper messageMapper) { this.messageMapper = messageMapper; @@ -26,15 +26,9 @@ public void addMessage(ChatForm chatForm) { ChatMessage newMessage = new ChatMessage(); newMessage.setUsername(chatForm.getUsername()); switch (chatForm.getMessageType()) { - case "Say": - newMessage.setMessageText(chatForm.getMessageText()); - break; - case "Shout": - newMessage.setMessageText(chatForm.getMessageText().toUpperCase()); - break; - case "Whisper": - newMessage.setMessageText(chatForm.getMessageText().toLowerCase()); - break; + case "Say" -> newMessage.setMessageText(chatForm.getMessageText()); + case "Shout" -> newMessage.setMessageText(chatForm.getMessageText().toUpperCase()); + case "Whisper" -> newMessage.setMessageText(chatForm.getMessageText().toLowerCase()); } messageMapper.addMessage(newMessage); }