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 *
* 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 *
* * @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 *
* 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 *
* 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; }