Skip to content

Commit

Permalink
Merge pull request #40 from nehbehl/patch-28
Browse files Browse the repository at this point in the history
Update MessageService.java
  • Loading branch information
SudKul authored Nov 18, 2024
2 parents 803de77 + d415b41 commit edc2847
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down

0 comments on commit edc2847

Please sign in to comment.