File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
src/main/java/com/nexters/teamace/chat Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 11package com .nexters .teamace .chat .domain ;
22
33import java .util .ArrayList ;
4- import java .util .Collections ;
4+ import java .util .Iterator ;
55import java .util .List ;
6+ import java .util .stream .Stream ;
7+ import java .util .stream .StreamSupport ;
68import lombok .EqualsAndHashCode ;
79
810@ EqualsAndHashCode
9- public class Chats {
11+ public class Chats implements Iterable < Chat > {
1012
1113 private final List <Chat > chats ;
1214
@@ -22,8 +24,13 @@ public void add(final Chat chat) {
2224 this .chats .add (chat );
2325 }
2426
25- public List <Chat > getChats () {
26- return Collections .unmodifiableList (chats );
27+ @ Override
28+ public Iterator <Chat > iterator () {
29+ return chats .iterator ();
30+ }
31+
32+ public Stream <Chat > stream () {
33+ return StreamSupport .stream (spliterator (), false );
2734 }
2835
2936 public int size () {
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ public ChatRoom toDomain(final ChatRoomEntity entity) {
1515
1616 public ChatRoomEntity toEntity (final ChatRoom domain ) {
1717 final ChatRoomEntity entity = new ChatRoomEntity (domain .getId (), domain .getUserId ());
18- domain .getChats ().getChats (). stream ().map (this ::toChatEntity ).forEach (entity ::addChat );
18+ domain .getChats ().stream ().map (this ::toChatEntity ).forEach (entity ::addChat );
1919 return entity ;
2020 }
2121
You can’t perform that action at this time.
0 commit comments