-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(UserRepository) : 임의의 DB 접근하는 Repository 객체 추가
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package client.repsotiroy; | ||
|
||
import client.model.User; | ||
import spring.mvc.annotation.Repository; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Repository | ||
public class UserRepository { | ||
private final Map<Long, User> temporaryDatabase = new HashMap<>(); | ||
private Long SEQUENCE = 0L; | ||
|
||
public void save(final User user) { | ||
temporaryDatabase.put(SEQUENCE++,user); | ||
} | ||
|
||
public List<User> getUsersWithLimit(int wannaSize) { | ||
List<User> allUsers = (List<User>) temporaryDatabase.values(); | ||
|
||
return allUsers.stream() | ||
.limit(wannaSize) | ||
.toList(); | ||
} | ||
} |