Interface ProblemCollector<P extends BuilderProblem>

Type Parameters:
P - The type of the problem.
All Known Implementing Classes:
ProblemCollector.Impl

@Experimental public interface ProblemCollector<P extends BuilderProblem>
Collects problems that were encountered during project building.
Since:
4.0.0
  • Method Details

    • hasWarningProblems

      default boolean hasWarningProblems()
      Returns true if there is at least one problem collected with severity equal or more severe than BuilderProblem.Severity.WARNING. This check is logically equivalent to "is there any problem reported?", given warning is the lowest severity.
    • hasErrorProblems

      default boolean hasErrorProblems()
      Returns true if there is at least one problem collected with severity equal or more severe than BuilderProblem.Severity.ERROR.
    • hasFatalProblems

      default boolean hasFatalProblems()
      Returns true if there is at least one problem collected with severity equal or more severe than BuilderProblem.Severity.FATAL.
    • hasProblemsFor

      default boolean hasProblemsFor(BuilderProblem.Severity severity)
      Returns true if there is at least one problem collected with severity equal or more severe than passed in severity.
    • totalProblemsReported

      default int totalProblemsReported()
      Returns total count of problems reported.
    • problemsReportedFor

      int problemsReportedFor(BuilderProblem.Severity... severities)
      Returns count of problems reported for given severities.
      Parameters:
      severities - the severity levels to count problems for
      Returns:
      the total count of problems for the specified severities
    • problemsOverflow

      boolean problemsOverflow()
      Returns true if reported problem count exceeded allowed count, and issues were lost. When this method returns true, it means that element count of stream returned by method problems() and the counter returned by totalProblemsReported() are not equal (latter is bigger than former).
      Returns:
      true if the problem collector has overflowed and some problems were not preserved
    • reportProblem

      boolean reportProblem(P problem)
      Reports a problem: always maintains the counters, but whether problem is preserved in memory, depends on implementation and its configuration.
      Parameters:
      problem - the problem to report
      Returns:
      true if passed problem is preserved by this call.
    • problems

      @Nonnull default Stream<P> problems()
      Returns all reported and preserved problems ordered by severity in decreasing order. Note: counters and element count in this stream does not have to be equal.
    • problems

      Returns all reported and preserved problems for given severity. Note: counters and element count in this stream does not have to be equal.
      Parameters:
      severity - the severity level to get problems for
      Returns:
      a stream of problems with the specified severity
    • empty

      @Nonnull static <P extends BuilderProblem> ProblemCollector<P> empty()
      Creates an "empty" problem collector that doesn't store any problems.
      Type Parameters:
      P - the type of problem
      Returns:
      an empty problem collector
    • create

      @Nonnull static <P extends BuilderProblem> ProblemCollector<P> create(@Nullable ProtoSession protoSession)
      Creates new instance of problem collector with configuration from the provided session.
      Type Parameters:
      P - the type of problem
      Parameters:
      protoSession - the session containing configuration for the problem collector
      Returns:
      a new problem collector instance
    • create

      @Nonnull static <P extends BuilderProblem> ProblemCollector<P> create(int maxCountLimit)
      Creates new instance of problem collector with the specified maximum problem count limit. Visible for testing only.
      Type Parameters:
      P - the type of problem
      Parameters:
      maxCountLimit - the maximum number of problems to preserve
      Returns:
      a new problem collector instance