com.jgoodies.validation.message
Class SimpleValidationMessage

java.lang.Object
  extended by com.jgoodies.validation.message.AbstractValidationMessage
      extended by com.jgoodies.validation.message.SimpleValidationMessage
All Implemented Interfaces:
ValidationMessage, Serializable

public final class SimpleValidationMessage
extends AbstractValidationMessage

A minimal implementation of ValidationMessage that just holds a text.

Version:
$Revision: 1.11 $
Author:
Karsten Lentzsch
See Also:
Serialized Form

Constructor Summary
SimpleValidationMessage(String text)
          Constructs a simple warning message for the given text.
SimpleValidationMessage(String text, Severity severity)
          Constructs a simple validation message for the given text and message severity.
SimpleValidationMessage(String text, Severity severity, Object key)
          Constructs a simple validation message for the given text, message severity, and message key.
 
Method Summary
 boolean equals(Object o)
          Compares the specified object with this validation message for equality.
 int hashCode()
          Returns the hash code value for this validation message.
 
Methods inherited from class com.jgoodies.validation.message.AbstractValidationMessage
formattedText, key, setKey, severity, text, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleValidationMessage

public SimpleValidationMessage(String text)
Constructs a simple warning message for the given text.

Parameters:
text - a String that describes this warning
Throws:
NullPointerException - if text is null.

SimpleValidationMessage

public SimpleValidationMessage(String text,
                               Severity severity)
Constructs a simple validation message for the given text and message severity.

Parameters:
text - describes this message
severity - the message severity, either error or warning
Throws:
NullPointerException - if text is null
IllegalArgumentException - if severity is OK

SimpleValidationMessage

public SimpleValidationMessage(String text,
                               Severity severity,
                               Object key)
Constructs a simple validation message for the given text, message severity, and message key.

Parameters:
text - describes this message
severity - the message severity, either error or warning
key - the message's key
Throws:
NullPointerException - if text is null
IllegalArgumentException - if severity is OK
Method Detail

equals

public boolean equals(Object o)
Compares the specified object with this validation message for equality. Returns true if and only if the specified object is also a simple validation message, both messages have the same severity, key, and formatted text. In other words, two simple validation messages are defined to be equal if and only if they behave one like the other.

This implementation first checks if the specified object is this a simple validation message. If so, it returns true; if not, it checks if the specified object is a simple validation message. If not, it returns false; if so, it checks and returns if the severities, keys and formatted texts of both messages are equal.

Overrides:
equals in class Object
Parameters:
o - the object to be compared for equality with this validation message.
Returns:
true if the specified object is equal to this validation message.
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Returns the hash code value for this validation message. This implementation computes and returns the hash based on the hash code values of this messages' severity, key, and text.

Overrides:
hashCode in class Object
Returns:
the hash code value for this validation message.
See Also:
Object.hashCode()


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