Class Problems

java.lang.Object
com.jk.core.validation.Problems

public final class Problems extends Object
This class represents a collection of problems or issues, each associated with a severity level.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    add(Problem problem)
    This method adds a problem with the specified severity level to the collection.
    final void
    add(String problem)
    This method adds a problem with a default severity level of "FATAL" to the collection.
    final void
    add(String problem, Severity severity)
    This method adds a problem with the specified severity level to the collection.
    final Problem
    This method retrieves the problem with the highest severity level from the collection.
    This method retrieves the list of problems stored in this collection.
    final boolean
    This method checks if any problem in the collection has a severity level of "FATAL".
    final boolean
    This method checks if the collection is empty (contains no problems).
    final void
    putAll(Problems problems)
    This method adds all problems from another Problems collection to this collection.
    This method appends the messages of all problems in the collection to a multi-line string.
    Returns a string representation of the object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Problems

      public Problems()
  • Method Details

    • add

      public final void add(Problem problem)
      This method adds a problem with the specified severity level to the collection.
      Parameters:
      problem - Specifies the problem to add.
    • add

      public final void add(String problem)
      This method adds a problem with a default severity level of "FATAL" to the collection.
      Parameters:
      problem - the problem
    • add

      public final void add(String problem, Severity severity)
      This method adds a problem with the specified severity level to the collection.
      Parameters:
      problem - Specifies the problem message to add.
      severity - Specifies the severity level of the problem.
    • getLeadProblem

      public final Problem getLeadProblem()
      This method retrieves the problem with the highest severity level from the collection.
      Returns:
      the problem with the highest severity level, or null if the collection is empty.
    • getProblemsList

      public List<Problem> getProblemsList()
      This method retrieves the list of problems stored in this collection.
      Returns:
      the list of problems.
    • hasFatal

      public final boolean hasFatal()
      This method checks if any problem in the collection has a severity level of "FATAL".
      Returns:
      true, if at least one problem has severity "FATAL," otherwise false.
    • isEmpty

      public final boolean isEmpty()
      This method checks if the collection is empty (contains no problems).
      Returns:
      true, if the collection is empty, otherwise false.
    • putAll

      public final void putAll(Problems problems)
      This method adds all problems from another Problems collection to this collection.
      Parameters:
      problems - Specifies the Problems collection from which to add problems.
    • toMutilLineString

      public String toMutilLineString()
      This method appends the messages of all problems in the collection to a multi-line string.
      Returns:
      a string containing each problem message on a separate line.
    • toString

      public String toString()
      Returns a string representation of the object.
      Overrides:
      toString in class Object
      Returns:
      the string representation of the object.