Package com.devonfw.cobigen.cli.utils
Class ValidationUtils
- java.lang.Object
-
- com.devonfw.cobigen.cli.utils.ValidationUtils
-
public final class ValidationUtils extends java.lang.ObjectUtilities class for validating user's input and generation
-
-
Constructor Summary
Constructors Constructor Description ValidationUtils()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidcheckGenerationReport(com.devonfw.cobigen.api.to.GenerationReportTo report)Checks the generation report in order to find possible errors and warningsstatic java.lang.StringgetUserInput()Asks the user for input and returns the valuestatic booleanisOutputRootPathValid(java.nio.file.Path outputRootPath)Checks whether the current output root path is valid.static voidthrowNoTriggersMatched(java.nio.file.Path inputFile, boolean isJavaInput, boolean isOpenApiInput)Prints an error message to the user informing that no triggers have been matched.booleanvalidateFile(java.io.File inputFile)Validating user input file is correct or not.static booleanyesNoPrompt(java.lang.String validInputMessage, java.lang.String invalidInputMessage, java.lang.String cancelMessage)Creates a simple looping yes/no prompt with customizable valid/invalid/cancel messages
-
-
-
Method Detail
-
validateFile
public boolean validateFile(java.io.File inputFile)
Validating user input file is correct or not. We check if file exists and it can be read- Parameters:
inputFile- user input file- Returns:
- true when file is valid
-
isOutputRootPathValid
public static boolean isOutputRootPathValid(java.nio.file.Path outputRootPath)
Checks whether the current output root path is valid. It can be either null because it is an optional parameter or either a folder that exists.- Parameters:
outputRootPath- where the user wants to generate the code- Returns:
- true if it is a valid output root path
-
checkGenerationReport
public static void checkGenerationReport(com.devonfw.cobigen.api.to.GenerationReportTo report)
Checks the generation report in order to find possible errors and warnings- Parameters:
report- the generation report returned by the CobiGen.generate method
-
throwNoTriggersMatched
public static void throwNoTriggersMatched(java.nio.file.Path inputFile, boolean isJavaInput, boolean isOpenApiInput)Prints an error message to the user informing that no triggers have been matched. Depending on the type of the input file will print different messages.- Parameters:
inputFile- User input fileisJavaInput- true when input file is JavaisOpenApiInput- true when input file is OpenAPI
-
getUserInput
public static java.lang.String getUserInput()
Asks the user for input and returns the value- Returns:
- String containing the user input
-
yesNoPrompt
public static boolean yesNoPrompt(java.lang.String validInputMessage, java.lang.String invalidInputMessage, java.lang.String cancelMessage)Creates a simple looping yes/no prompt with customizable valid/invalid/cancel messages- Parameters:
validInputMessage- String for a message in case of a valid inputinvalidInputMessage- String for a message in case of an invalid inputcancelMessage- String for a message in case the user cancelled the process- Returns:
- boolean decision of the user
-
-