Class Severity

java.lang.Object
com.nfbsoftware.util.Severity

public final class Severity extends Object
0 = (reserved error) 1 = Fatal 2 = Error 3 = Warning 4 = Informational 5 = Success 6 = Debug 7 = (reserved success)
Author:
Brendan Clemenzi
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Severity level is "DEBUG"; this is considered a success, but also will provide debug information.
    static final int
    Severity level is "ERROR"; this is considered a failure.
    static final int
    Severity level is "FATAL"; this is considered a failure.
    static final int
    Severity level is "INFORMATIONAL"; this is considered a success.
    static final int
    Severity level is "SUCCESS"; this is considered a success.
    static final int
    Severity level is "WARNING"; this is considered a failure.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    asInt(String severityStr)
    Returns a string representing the severity of the code.
    static String
    asString(int severity)
    Returns a string representing the severity of the code.
    static boolean
    atOrAbove(int severity, int threshold)
    Returns true if the severity is at or above the threshold.
    static boolean
    isFailure(int severity)
    Returns true if the severity of the code is one of the types of severities representing an "error" (which are Warning, Error, Fatal)
    static boolean
    isSuccess(int severity)
    Returns true if the severity of the code is one of the types of severities representing a "success (which are Success, Informational, Debug)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FATAL

      public static final int FATAL
      Severity level is "FATAL"; this is considered a failure.
      See Also:
    • ERROR

      public static final int ERROR
      Severity level is "ERROR"; this is considered a failure.
      See Also:
    • WARNING

      public static final int WARNING
      Severity level is "WARNING"; this is considered a failure.
      See Also:
    • INFORMATIONAL

      public static final int INFORMATIONAL
      Severity level is "INFORMATIONAL"; this is considered a success.
      See Also:
    • SUCCESS

      public static final int SUCCESS
      Severity level is "SUCCESS"; this is considered a success.
      See Also:
    • DEBUG

      public static final int DEBUG
      Severity level is "DEBUG"; this is considered a success, but also will provide debug information.
      See Also:
  • Constructor Details

    • Severity

      public Severity()
  • Method Details

    • asString

      public static String asString(int severity)
      Returns a string representing the severity of the code.
      Parameters:
      severity - The severity's integer level.
      Returns:
      The first letter of the corresponding Severity level; if the integer does not match any of the severity levels it will return "E" for ERROR.
    • asInt

      public static int asInt(String severityStr)
      Returns a string representing the severity of the code.
      Parameters:
      severityStr - A single letter representation of the Severity levels.
      Returns:
      The corresponding int value of the letter. It will return the ERROR value if there are no matches.
    • isFailure

      public static boolean isFailure(int severity)
      Returns true if the severity of the code is one of the types of severities representing an "error" (which are Warning, Error, Fatal)
      Parameters:
      severity - The integer value of the Severity level
      Returns:
      Whether or not the severity is a failure.
    • isSuccess

      public static boolean isSuccess(int severity)
      Returns true if the severity of the code is one of the types of severities representing a "success (which are Success, Informational, Debug)
      Parameters:
      severity - The integer value of the Severity level
      Returns:
      Whether or not the severity is a success.
    • atOrAbove

      public static boolean atOrAbove(int severity, int threshold)
      Returns true if the severity is at or above the threshold. To be "above" implies the same or greater degree of error severity.
      Example: int sev = Severity.INFORMATIONAL;
      Severity.above(sev, Severity.WARNING) is false
      Severity.above(sev, Severity.DEBNUG) is true
      NOTE: Because of the way the severity levels are ordered, higher severities are actually lower integers. However, this should be irrelevant to the application since it should not try to do its own comparison of these values.
      Parameters:
      severity - The int Severity level.
      threshold - The int threshold level.
      Returns:
      true if the severity is at or above the threshold.