Stop a java processing

Asked

Viewed 60 times

0

I have a processing with a class calling another.

Example:

I have the registro0100. In it I call the ED022, ED021, etc.....

In this ED022, I have some validations, example:

boolean achou = false;
if (modulo.equals("2")) {
    String[] linhaSeparada = listaParametros.get(5).split(Pattern.quote("|"));
    if (linhaSeparada[0].equals(tipoCnso)) {
        achou = true;
    }
}
if (!achou) {
    apontandoErroAlerta(arquivo, erroAlerta, tipoRegistroCampo, tipoRegistro, erroAlertaEncontradoRepository,
    erroAlertaCampoEncontradoRepository, tipoCnso, contadorLinha, registro, erroAlertaRepository,
    tipoRegistroCampoRepository, tipoRegistroRepository);
        return;
}

If the variable found turns true, it points out the error and should stop the process. But not to.

Shouldn’t go into error ED021, but it will.

How to stop the process even.

  • Maybe if you return to your Registration Class0100 a boolean, could test whether "found" or not there, and then prevents the method to continue running.

  • @Pauloh.Hartmann, I had already imagined this, but I didn’t want it like this. Don’t you have another possibility ? Make an exception without a message. I didn’t want to make this return, because it’s a lot of class connecting to each other. .

  • I will try to put a better example: I wanted to know how to start a process, either in any class, without returning. I have the registration classes 0100, ED022, ED023 Error The process starts in the registration class 0100. The registered class 0100, calls the class ED022 If the class ED022 has an error calling the class Error and for the process in the class Error If the class ED022 has no error, call the class ED021 If the class ED023, have error call the class Error and for the process in the class Error ?

  • Perhaps the Observer design pattern would not help you? https://www.tutorialspoint.com/design_pattern/observer_pattern.htm e https://answall.com/questions/36655/como-funciona-e-como-implementar-o-design-pattern-observer

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.