Package com.example.common.input
Class Input<T>
java.lang.Object
com.example.common.input.Input<T>
This class represents an abstract input class that handles user input.
It provides methods for retrieving user input and validating it using a ValidatorInterface.
It also contains messages for welcoming and error messages to be displayed to the user.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String
getInputValue
(String headerMessage) Retrieves input from the user and returns it as a string.protected abstract ValidatorInterface
getValidator
(String text) Abstract method to get the appropriate validator for the input text.abstract T
getValue()
Abstract method to get the user input of type T.protected String
Gets user input after validating it with the specified ValidatorInterface.
-
Constructor Details
-
Input
public Input()
-
-
Method Details
-
getInputValue
Retrieves input from the user and returns it as a string.- Parameters:
headerMessage
- The message to display when prompting the user for input.- Returns:
- The user input as a string.
-
getValueAfterValidation
Gets user input after validating it with the specified ValidatorInterface.- Returns:
- The validated user input as a string.
-
getValidator
Abstract method to get the appropriate validator for the input text.- Parameters:
text
- The user input text to be validated.- Returns:
- The ValidatorInterface implementation for the input text.
-
getValue
Abstract method to get the user input of type T.- Returns:
- The user input of type T.
-