blob: 27ba0b992ecd6a6bb9cdce7a877061995844fb34 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
package com.ufund.api.ufundapi.persistence;
import java.io.IOException;
import com.ufund.api.ufundapi.model.User;
/**
* Defines the interface for User object persistence
*
* @author Team 2B Jelly Solutions
*/
public interface UserDAO {
/**
* Retrieves all {@linkplain User users}
*
* @return An array of {@link User user} objects, may be empty
*
* @throws IOException if an issue with underlying storage
*/
User[] getUsers() throws IOException;
/**
* Retrieves a {@linkplain User user} with the given username
*
* @param username The ID of the {@link User user} to get
*
* @return a {@link User user} object with the matching username
* <br>
* null if no {@link User user} with a matching username is found
*
* @throws IOException if an issue with underlying storage
*/
User getUser(String username) throws IOException;
/**
* Retrieves the total count of users
*
* @return a {@link int amount} number of users
* <br>
*
* @throws IOException if an issue with underlying storage
*/
int getUserCount() throws IOException;
/**
* Creates and saves a {@linkplain User user}
*
* @param user {@linkplain User user} object to be created and saved
* <br>
* The id of the user object is automatically incremented.
*
* @return new {@link User user} if successful, null otherwise
*
* @throws IOException if an issue with underlying storage
*/
User addUser(User user) throws IOException;
/**
* Updates and saves a {@linkplain User user}
*
* @param user {@link User user} object to be updated and saved
*
* @return updated {@link User user} if successful, null if
* {@link User user} could not be found
*
* @throws IOException if underlying storage cannot be accessed
*/
User updateUser(User user) throws IOException;
/**
* Deletes a {@linkplain User user} with the given id
*
* @param username The id of the {@link User user}
*
* @return true if the {@link User user} was deleted
* <br>
* false if the user with the given id does not exist
*
* @throws IOException if underlying storage cannot be accessed
*/
boolean deleteUser(String username) throws IOException;
}
|