Skip to content

Commit

Permalink
Merge pull request #63 from CSC207-2022F-UofT/xgao28_userjoin_javadoc
Browse files Browse the repository at this point in the history
[+] Added javadoc for userjoin use case.
  • Loading branch information
Lei-Tin authored Nov 29, 2022
2 parents f5b82b1 + ef6bbff commit e252c05
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/billgates/interface_adapters/UserJoinUpdatable.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@

import billgates.use_cases.user_join.UserJoinViewModel;

/**
* Clean Architecture Layer: Interface Adapters
* An interface represents that a view is updatable with respect to the <code>UserJoinViewModel</code>.
* The purpose of this interface is dependency inversion.
*
* @author Xinxiang
* @see UserJoinViewModel
*/
public interface UserJoinUpdatable {

/**
* Updates the table according to the <code>viewModel</code>.
*
* @param viewModel a data structure specifying the data required for this update.
*/
void view(UserJoinViewModel viewModel);

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package billgates.use_cases.user_join;

/**
* Clean Architecture Layer: Interface Adapters
* This class serves as the controller of the User Join Use Case.
* It is only responsible for accepting the input (<code>username</code>,
* <code>password</code>) from the user and invoke the corresponding use case.
*
* @author Xinxiang
* @see UserJoinInputPort
*/
public class UserJoinController {

private final UserJoinInputPort useCase;
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/billgates/use_cases/user_join/UserJoinInputPort.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
package billgates.use_cases.user_join;

/**
* Clean Architecture Layer: Application Business Rules
* An input port for the User Join use case.
*
* @author Xinxiang
* @see UserJoinUseCase
*/
public interface UserJoinInputPort {

/**
* This method will detect 3 different scenarios from the
* <code>UserJoinRequestModel</code> model and take following actions:
* Case 1: If the username is not in the database,
* a new user is created and recorded in the database. i.e, register a new user.
* Case 2: If the username is in the database and the password matches,
* the corresponding user is logged in.
* Case 3: If the username is in the database and the password doesn't match,
* either the username is not valid for a register or the password is incorrect,
* and the corresponding user is not logged in.
* @param model the model that needs certain actions above.
*/
void join(UserJoinRequestModel model);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
package billgates.use_cases.user_join;

/**
* Clean Architecture Layer: Application Business Rules
* An output port for the User Join use case.
* The purpose of this interface is dependency inversion.
*
* @author Xinxiang
* @see UserJoinUseCase
* @see UserJoinPresenter
*/
public interface UserJoinOutputPort {

/**
* Converts the data in model to a GUI-friendly format and
* updates the GUI correspondingly.
*
* @param model the model to convert.
*/
void display(UserJoinResponseModel model);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

import billgates.interface_adapters.UserJoinUpdatable;

/**
* Clean Architecture Layer: Interface Adapters
* A presenter in Clean Architecture for the User Join use case.
* This presenter is implemented based on the MVC architecture.
*
* @author Xinxiang
* @see UserJoinUpdatable
*/
public class UserJoinPresenter implements UserJoinOutputPort {

private UserJoinUpdatable view;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
package billgates.use_cases.user_join;

/**
* Clean Architecture Layer: Application Business Rules
* A request model of the User Join use case.
* It is used to transfer input username and password as a whole
* from the controller to the use case.
*
* @author Xinxiang
* @see UserJoinInputPort
* @see UserJoinUseCase
* @see UserJoinController
*/
public class UserJoinRequestModel {
private String username;
private String password;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package billgates.use_cases.user_join;

/**
* Clean Architecture Layer: Application Business Rules
* A response model of the User Join use case.
* It is used to transfer data from the use case to the presenter.
*
* @author Xinxiang
* @see UserJoinUseCase
* @see UserJoinOutputPort
* @see UserJoinPresenter
*/
public class UserJoinResponseModel {

private boolean isJoined;
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/billgates/use_cases/user_join/UserJoinUseCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,26 @@

import java.util.List;

/**
* Clean Architecture Layer: Application Business Rules
* A concrete implementation of the <code>UserJoinInputPort</code>.
*
* @author Xinxiang, Scott, Charlotte
* @see UserJoinInputPort
* @see UserJoinPresenter
* @see UserJoinRequestModel
*/

public class UserJoinUseCase implements UserJoinInputPort {

/**
* The presenter for converting the response model to a view model.
*/
private final DatabaseGateway gateway;

/**
* The database gateway for input/output with the database.
*/
private final UserJoinOutputPort outputPort;

public UserJoinUseCase(DatabaseGateway gateway, UserJoinOutputPort outputPort) {
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/billgates/use_cases/user_join/UserJoinViewModel.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
package billgates.use_cases.user_join;

/**
* Clean Architecture Layer: Interface Adapters
* A view model holding information for the GUI to display.
*
* @author Xinxiang
* @see billgates.interface_adapters.UserJoinUpdatable
* @see UserJoinPresenter
*/
public class UserJoinViewModel {

/**
* Whether the user is joined.
*/
private boolean isJoined;
/**
* The reason that the view model is presented.
*/
private String reasonRejected;

public UserJoinViewModel(boolean isJoined, String reasonRejected) {
Expand Down

0 comments on commit e252c05

Please sign in to comment.