com.jgoodies.validation
Class Severity

java.lang.Object
  extended by com.jgoodies.validation.Severity
All Implemented Interfaces:
Serializable, Comparable

public final class Severity
extends Object
implements Comparable, Serializable

A typesafe enumeration for the different severities used in instances of ValidationMessage. Useful to categorize validation results, for example to prevent an object from being saved if the primary key is missing. It is an ordinal-based comparable and serializable enumeration implementation that is not extensible.

The severity is used in almost all views that present validation messages and is used in operations on instances of ValidationResult.

Version:
$Revision: 1.3 $
Author:
Karsten Lentzsch
See Also:
ValidationMessage, ValidationResult, Serialized Form

Field Summary
static Severity ERROR
          Indicates a problem that cannot be resumed or worked around.
static Severity OK
          Returned by empty validation results to indicate that no problem has been detected, or in other words, everything is fine.
static Severity WARNING
          Indicates a problem that can be resumed or handled in a reasonable way.
 
Method Summary
 int compareTo(Object o)
          Compares this object with the specified object for order.
static Severity max(Severity severity1, Severity severity2)
          Returns the higher of the given severities by comparing their ordinals.
 String toString()
          Returns the name this object's string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ERROR

public static final Severity ERROR
Indicates a problem that cannot be resumed or worked around. For example it prevents an edited value to be saved.


WARNING

public static final Severity WARNING
Indicates a problem that can be resumed or handled in a reasonable way. For example a field value may break a constraint but the object can be temporarily saved.


OK

public static final Severity OK
Returned by empty validation results to indicate that no problem has been detected, or in other words, everything is fine.

Method Detail

toString

public String toString()
Returns the name this object's string representation.

Overrides:
toString in class Object
Returns:
this object's name

compareTo

public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

This implementation is consistent with #equals, i. e. (x.compareTo(y)==0) == (x.equals(y)).

The implementation is based on the internal ordinal.

Specified by:
compareTo in interface Comparable
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
ClassCastException - if the specified object's type prevents it from being compared to this Object.

max

public static Severity max(Severity severity1,
                           Severity severity2)
Returns the higher of the given severities by comparing their ordinals. Since the higher severities have a lower ordinal, this method returns the severity with the lower ordinal.

Parameters:
severity1 - the first severity to check
severity2 - the second severity to check
Returns:
the higher of the given severities


Copyright © 2003-2007 JGoodies Karsten Lentzsch. All Rights Reserved.