Enum Class CLI

java.lang.Object
java.lang.Enum<CLI>
userinterface.CLI
All Implemented Interfaces:
Serializable, Comparable<CLI>, Constable

public enum CLI extends Enum<CLI>
Singleton command-line interface controller responsible for parsing user input to create blanked and filled-in madlibs. Enum singleton to maintain thread safety, readability, and serialization.
Author:
Adam Barnett
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final Pattern
    Parsing logic to ensure user is inputting valid numbers when prompted
    private static final Scanner
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    CLI()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static CLI
    Used by Main to begin program logic
    private String
    Helper method to ensure user is entering a proper numerical value for the madlibifiable skipper variable
    private Queue<String>
    Prompt user to enter words one at a time based on the parts of speech of the words removed during madlib blanking
    private Path
    Parsing logic to obtain a valid filepath for the text to be madlibified
    void
    Main controller logic that facilitates the madlib creation process in steps by requesting filenames, calling helper methods, and confirming successful text processing
    private boolean
    Helper method that determines if CLI should prompt the user for parts of speech or end the program.
    static CLI
    Returns the enum constant of this class with the specified name.
    static CLI[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • INSTANCE

      public static final CLI INSTANCE
  • Field Details

    • SCANNER

      private static final Scanner SCANNER
    • DIGITS

      private static final Pattern DIGITS
      Parsing logic to ensure user is inputting valid numbers when prompted
  • Constructor Details

    • CLI

      private CLI()
  • Method Details

    • values

      public static CLI[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static CLI valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getInstance

      public static CLI getInstance()
      Used by Main to begin program logic
    • initiateMadlibCreation

      public void initiateMadlibCreation() throws NullPointerException, utility.exceptions.TextNotProcessedException, IOException, utility.exceptions.NullPOSListException
      Main controller logic that facilitates the madlib creation process in steps by requesting filenames, calling helper methods, and confirming successful text processing
      Throws:
      NullPointerException
      utility.exceptions.TextNotProcessedException
      IOException
      utility.exceptions.NullPOSListException
    • getSourceTxtFile

      private Path getSourceTxtFile(String filepath)
      Parsing logic to obtain a valid filepath for the text to be madlibified
    • getMadlibifiableSkipper

      private String getMadlibifiableSkipper()
      Helper method to ensure user is entering a proper numerical value for the madlibifiable skipper variable
    • queryFillInMadlib

      private boolean queryFillInMadlib()
      Helper method that determines if CLI should prompt the user for parts of speech or end the program. If user decides to enter parts of speech, the CLI will call getReplacementWords. Otherwise, it ends the program.
    • getReplacementWords

      private Queue<String> getReplacementWords(List<String> posList) throws utility.exceptions.NullPOSListException
      Prompt user to enter words one at a time based on the parts of speech of the words removed during madlib blanking
      Parameters:
      posList - CLI iterates over the parts of speech in order so that the user can enter replacement words in order of when they appear in the text
      Returns:
      Returns the list of words in a queue for cleaner replacement when filling in the madlib; no indexing required, and constant time removal better handles errors involved in case the list empties before madlib filling is complete.
      Throws:
      utility.exceptions.NullPOSListException