public abstract class AbstractValidationMessage extends Object implements ValidationMessage, Serializable
ValidationMessage
interface. Holds the severity, a text message,
and the association key.
Subclasses should implement #equals
and #hashCode
to prevent unnecessary change notifications for the result property
when a ValidationResultModel gets a new ValidationResult. See for example
the implementation of method PropertyValidationMessage.equals(Object)
.
Modifier | Constructor and Description |
---|---|
protected |
AbstractValidationMessage(String text,
Severity severity)
Constructs an AbstractValidationMessage for the given text and Severity.
|
protected |
AbstractValidationMessage(String text,
Severity severity,
Object key)
Constructs an AbstractValidationMessage for the given text,
Severity, and association key.
|
Modifier and Type | Method and Description |
---|---|
String |
formattedText()
Returns a message description as formatted text.
|
Object |
key()
Returns this message's association key that can be used to model
a loose coupling between validation messages and views that present
the validated data.
|
protected void |
setKey(Object associationKey)
Sets the given object as new association key.
|
Severity |
severity()
Returns this message's severity, either error or warning.
|
protected String |
text()
Returns this validation message's text.
|
String |
toString()
Returns a string representation of this validation message.
|
protected AbstractValidationMessage(String text, Severity severity)
text
- describes this messageseverity
- this message's severity, either error or warningIllegalArgumentException
- if severity
is OK
protected AbstractValidationMessage(String text, Severity severity, Object key)
text
- describes this messageseverity
- this message's severity, either error or warningkey
- used to determine whether this message belongs
to a given viewIllegalArgumentException
- if severity
is OK
public final Severity severity()
severity
in interface ValidationMessage
public String formattedText()
formattedText
in interface ValidationMessage
protected final String text()
public Object key()
Subclasses may override this method to return keys that are built from
other internal data. For example, the PropertyValidationMessage
returns the aspect as key.
See the class comment for more information about this relation.
key
in interface ValidationMessage
protected final void setKey(Object associationKey)
associationKey
- the key to be setpublic String toString()
toString
in class Object
Object.toString()
Copyright © 2003-2011 JGoodies Karsten Lentzsch. All Rights Reserved.