Class ValidationResult

java.lang.Object
com.amalgamasimulation.validation.ValidationResult

public class ValidationResult extends Object
The result of one scenario check: the list of found problems (Problem) in the order they were added.

The check code of an application creates one ValidationResult for one check and passes it to the Checks constructor. Checks and its copies from Checks.warnings() and Checks.onTab(String) add problems to this same object. Code can also add a problem directly with add(Problem).

After the check, an application usually sends the result to the topic PlatformTopics.VALIDATION_FINISHED. AbstractProblemsPart shows it as a tree: errors first, then warnings, and inside them groups by object type. An application can use hasErrors() to block an action, for example a simulation run, while the scenario has errors.

The class does not remove duplicates: if the same problem is added twice, the list contains it twice. The class is not thread-safe, so add problems from one thread.

  • Constructor Details

    • ValidationResult

      public ValidationResult()
  • Method Details

    • add

      public void add(Problem problem)
      Adds a problem to the end of the list.
      Parameters:
      problem - the problem to add, not null; the method does not check for null, but hasErrors() then throws NullPointerException
    • getProblems

      public List<Problem> getProblems()
      Returns all problems in the order they were added.

      The list is read-only and stays connected to this result: problems added later also appear in it. To keep a snapshot, copy the list.

      Returns:
      a read-only view of the problems; an empty list if there are no problems
    • hasErrors

      public boolean hasErrors()
      Checks whether the result has at least one problem with the Problem.Severity.ERROR severity. The method ignores warnings (Problem.Severity.WARNING).
      Returns:
      true if there is at least one error; false if there are no problems or all of them are warnings