Class Input<T>

java.lang.Object
com.example.common.input.Input<T>
Direct Known Subclasses:
InputIp, InputPort

public abstract class Input<T> extends Object
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 Details

    • Input

      public Input()
  • Method Details

    • getInputValue

      protected String getInputValue(String headerMessage)
      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

      protected String getValueAfterValidation()
      Gets user input after validating it with the specified ValidatorInterface.
      Returns:
      The validated user input as a string.
    • getValidator

      protected abstract ValidatorInterface getValidator(String text)
      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

      public abstract T getValue()
      Abstract method to get the user input of type T.
      Returns:
      The user input of type T.