Class ResultCaller


  • public final class ResultCaller
    extends Object
    The ResultCaller class 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 Detail

      • ResultCaller

        public ResultCaller​(List<String> errorMessages)
        Constructs a ResultCaller instance with the provided list of error messages. This constructor initializes an internal StringBuilder used 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.