diff options
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java')
-rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java new file mode 100644 index 0000000..d456abc --- /dev/null +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java @@ -0,0 +1,74 @@ +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 name + * + * @param id The ID of the {@link User user} to get + * + * @return a {@link User user} object with the matching name + * <br> + * null if no {@link User user} with a matching name is found + * + * @throws IOException if an issue with underlying storage + */ + User getUser(String name) 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 createUser(User user) throws IOException; + + /** + * Updates and saves a {@linkplain User user} + * + * @param newUser {@link User user} object to be updated and saved + * @param name {@link String name} name of object to be updated + * + * @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 newUser, String name) throws IOException; + + /** + * Deletes a {@linkplain User user} with the given id + * + * @param id 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 name) throws IOException; +} |