35
35
import java .util .Arrays ;
36
36
import java .util .HashMap ;
37
37
import java .util .HashSet ;
38
+ import java .util .List ;
38
39
import java .util .Map ;
39
40
import java .util .Optional ;
41
+ import java .util .Set ;
40
42
41
43
/**
42
44
* Mongo lottery ticket database
@@ -142,7 +144,7 @@ public MongoCollection<Document> getCountersCollection() {
142
144
@ Override
143
145
public Optional <LotteryTicket > findById (LotteryTicketId id ) {
144
146
Document find = new Document ("ticketId" , id .getId ());
145
- ArrayList <Document > results = ticketsCollection .find (find ).limit (1 ).into (new ArrayList <Document >());
147
+ List <Document > results = ticketsCollection .find (find ).limit (1 ).into (new ArrayList <Document >());
146
148
if (results .size () > 0 ) {
147
149
LotteryTicket lotteryTicket = docToTicket (results .get (0 ));
148
150
return Optional .of (lotteryTicket );
@@ -166,7 +168,7 @@ public Optional<LotteryTicketId> save(LotteryTicket ticket) {
166
168
@ Override
167
169
public Map <LotteryTicketId , LotteryTicket > findAll () {
168
170
Map <LotteryTicketId , LotteryTicket > map = new HashMap <>();
169
- ArrayList <Document > docs = ticketsCollection .find (new Document ()).into (new ArrayList <Document >());
171
+ List <Document > docs = ticketsCollection .find (new Document ()).into (new ArrayList <Document >());
170
172
for (Document doc : docs ) {
171
173
LotteryTicket lotteryTicket = docToTicket (doc );
172
174
map .put (lotteryTicket .getId (), lotteryTicket );
@@ -183,7 +185,7 @@ private LotteryTicket docToTicket(Document doc) {
183
185
PlayerDetails playerDetails = new PlayerDetails (doc .getString ("email" ), doc .getString ("bank" ),
184
186
doc .getString ("phone" ));
185
187
int [] numArray = Arrays .asList (doc .getString ("numbers" ).split ("," )).stream ().mapToInt (Integer ::parseInt ).toArray ();
186
- HashSet <Integer > numbers = new HashSet <>();
188
+ Set <Integer > numbers = new HashSet <>();
187
189
for (int num : numArray ) {
188
190
numbers .add (num );
189
191
}
0 commit comments