Class ResultCaller
- java.lang.Object
-
- nl.zerofiftyit.mdepunit.core.validation.ResultCaller
-
public final class ResultCaller extends Object
TheResultCallerclass serves as a utility for managing and validating potential error states during operations. It allows for the accumulation of error messages and provides mechanisms to validate these errors, throwing exceptions when the validation fails.This class is always its methods are always terminator of an analysis. Without it won't display the potential errors.
-
-
Constructor Summary
Constructors Constructor Description ResultCaller(List<String> errorMessages)Constructs aResultCallerinstance with the provided list of error messages.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckForErrors()Appends all error messages to the internal string builder if any error messages are present in the instance.voidclearErrors()Clears error messages and resets the internal state.voidvalidate()Validates the current instance by checking for any accumulated error messages.voidvalidate(@NonNull String reason)Validates the current instance with a specific reason for validation.
-
-
-
Constructor Detail
-
ResultCaller
public ResultCaller(List<String> errorMessages)
Constructs aResultCallerinstance with the provided list of error messages. This constructor initializes an internalStringBuilderused for assembling error details when validation methods are invoked.- Parameters:
errorMessages- the list of error messages to be managed by this instance
-
-
Method Detail
-
validate
public void validate()
Validates the current instance by checking for any accumulated error messages. If error messages are present, invokes the error display mechanism.This method is typically used to ensure the integrity of the instance based on predefined validation rules. It throws an exception with details about the validation errors if any are found.
- Throws:
PomValidationException- if validation fails due to the presence of error messages.
-
validate
public void validate(@NonNull @NonNull String reason)Validates the current instance with a specific reason for validation. This method prepends the provided reason to any error messages before performing the validation check.- Parameters:
reason- the reason for validation, which will be included in any error message- Throws:
PomValidationException- if validation fails due to the presence of error messages
-
checkForErrors
public void checkForErrors()
Appends all error messages to the internal string builder if any error messages are present in the instance.This method does not clear the list of error messages or throw an exception. It simply collects and formats the errors into the internal string builder.
This method is typically used internally to prepare error messages for further operations such as validation or displaying errors.
-
clearErrors
public void clearErrors()
Clears error messages and resets the internal state.
-
-