Class ChatSetupControllerBuilder
java.lang.Object
ai.tutor.cab302exceptionalhandlers.builders.ControllerBuilder<ChatSetupController>
ai.tutor.cab302exceptionalhandlers.builders.ChatSetupControllerBuilder
Builder for creating instances of
ChatSetupController
.
This class allows for the construction of either a ChatCreateController
or a ChatUpdateController
based on the specified ChatSetupType
.
It requires the current user and, for updates, the specific chat to be modified.
Usage Example (Create):
ChatSetupController createController = controllerFactory.chatSetupController() .currentUser(user) .type(ChatSetupType.CREATE) .build();
Usage Example (Update):
ChatSetupController updateController = controllerFactory.chatSetupController() .currentUser(user) .type(ChatSetupType.UPDATE) .currentChat(chatToUpdate) .build();
- Author:
- Justin.
- See Also:
-
Field Summary
Fields inherited from class ai.tutor.cab302exceptionalhandlers.builders.ControllerBuilder
db
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aChatSetupControllerBuilder
. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds aChatSetupController
(eitherChatCreateController
orChatUpdateController
) based on the specified type and parameters.Builds aChatCreateController
.Builds aChatUpdateController
for the given chat.currentChat
(Chat chat) Sets the current chat, required for update operations.currentUser
(User user) Sets the current authenticated user.type
(ChatSetupType type) Sets the type of chat setup operation (CREATE or UPDATE).
-
Constructor Details
-
ChatSetupControllerBuilder
Constructs aChatSetupControllerBuilder
.- Parameters:
db
- TheSQLiteConnection
to be used for database operations.
-
-
Method Details
-
currentUser
Sets the current authenticated user.- Parameters:
user
- The authenticatedUser
.- Returns:
- This
ChatSetupControllerBuilder
instance for chaining.
-
type
Sets the type of chat setup operation (CREATE or UPDATE).- Parameters:
type
- TheChatSetupType
specifying the operation.- Returns:
- This
ChatSetupControllerBuilder
instance for chaining.
-
currentChat
Sets the current chat, required for update operations.- Parameters:
chat
- TheChat
to be updated.- Returns:
- This
ChatSetupControllerBuilder
instance for chaining.
-
build
Builds aChatSetupController
(eitherChatCreateController
orChatUpdateController
) based on the specified type and parameters.- Specified by:
build
in classControllerBuilder<ChatSetupController>
- Returns:
- An instance of
ChatSetupController
. - Throws:
IllegalStateException
- if required parameters (currentUser, setupType, or currentChat for UPDATE) are not set.RuntimeException
- if a database connection error occurs during controller construction.SQLException
- if a database access error occurs during controller construction.
-
buildCreate
public ChatCreateController buildCreate() throws IllegalStateException, RuntimeException, SQLExceptionBuilds aChatCreateController
. RequirescurrentUser
to be set.- Returns:
- A new instance of
ChatCreateController
. - Throws:
IllegalStateException
- if the current user is not set.RuntimeException
- if a database connection error occurs during controller construction.SQLException
- if a database access error occurs during controller construction.
-
buildUpdate
public ChatUpdateController buildUpdate() throws IllegalStateException, RuntimeException, SQLException- Returns:
- A new instance of
ChatUpdateController
. - Throws:
IllegalStateException
- if the current user or selected chat is not set.RuntimeException
- if a database connection error occurs during controller construction.SQLException
- if a database access error occurs during controller construction.
-