Package com.onwbp.base.text
Class Severity
- java.lang.Object
-
- com.onwbp.base.text.Severity
-
public final class Severity extends Object
This enumeration class defines the possible severity levels of user messages.- See Also:
UserMessage
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Map<Severity,UserMessage>
getAllSeveritiesWithLabel()
Returns a map from the available severities to their corresponding user message.String
getLabel()
boolean
isEqualOrMoreSevereThan(Severity anotherSeverity)
Returnstrue
if this severity level is equal to or higher than the one specified.boolean
isError()
boolean
isFatal()
boolean
isInfo()
boolean
isWarning()
static Severity
parseFlag(String aFlag)
Returns the severity instance corresponding to the flag specified.static Severity
parseLabel(String aLabel)
Returns the severity instance that corresponds with the label specified.String
toParsableString()
Returns a flag identifying the severity.String
toString()
-
-
-
Field Detail
-
FATAL
public static final Severity FATAL
Specifies a "fatal" error, the highest severity.
-
ERROR
public static final Severity ERROR
Specifies an error.
-
WARNING
public static final Severity WARNING
Specifies a warning.
-
INFO
public static final Severity INFO
Specifies an information message, the lowest severity.
-
-
Method Detail
-
parseFlag
public static Severity parseFlag(String aFlag) throws IllegalArgumentException
Returns the severity instance corresponding to the flag specified. The flag should have been generated by methodtoParsableString()
.- Throws:
IllegalArgumentException
- if aFlag does not have the format expected, or if it is not recognized.
-
parseLabel
public static Severity parseLabel(String aLabel) throws IllegalArgumentException
Returns the severity instance that corresponds with the label specified. The label should have been generated by methodgetLabel()
.- Throws:
IllegalArgumentException
- if aLabel is not recognized.
-
getLabel
public String getLabel()
-
toParsableString
public String toParsableString()
Returns a flag identifying the severity. The returned string can be converted back into aSeverity
instance using methodparseFlag(String)
.
-
isFatal
public boolean isFatal()
-
isError
public boolean isError()
-
isWarning
public boolean isWarning()
-
isInfo
public boolean isInfo()
-
isEqualOrMoreSevereThan
public boolean isEqualOrMoreSevereThan(Severity anotherSeverity)
Returnstrue
if this severity level is equal to or higher than the one specified.The order of severity levels is as follows:
FATAL > ERROR > WARNING > INFO
-
getAllSeveritiesWithLabel
public static Map<Severity,UserMessage> getAllSeveritiesWithLabel()
Returns a map from the available severities to their corresponding user message.
-
-