public class ValidationStateMessageCollector extends AbstractValidationStateCollector
ValidationState
that wraps an existing ValidationState
and allows to
collect the potential
messages
for a
part of the validation process. public booleanvalidate
(ValidationState
state) { if (state == null) { state = newValidationStateImpl
(); }ValidationStateMessageCollector
messageCollector = newValidationStateMessageCollector
(state); validateRecursive(messageCollector); String messages = messageCollector.getFailureMessages(); if (messages != null) { setTooltip(messages); setStyle("invalid"); } else { setTooltip(""); setStyle("valid"); } return messageCollector.isValid()
; }
Modifier and Type | Field and Description |
---|---|
private StringBuilder |
failureMessages |
private String |
separator |
Constructor and Description |
---|
ValidationStateMessageCollector(ValidationState delegate)
The constructor.
|
ValidationStateMessageCollector(ValidationState delegate,
String separator)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
String |
getFailureMessages()
|
String |
getSeparator()
This method gets the
String used to separate individual validation
failure messages for getFailureMessages() . |
boolean |
isValid()
This method determines if the
validation has been
successful. |
void |
onFailure(ValidationFailure failure)
This method gets called if a
ValidationFailure occurred. |
String |
toString() |
getDelegate, getFailureCount
private final String separator
private StringBuilder failureMessages
public ValidationStateMessageCollector(ValidationState delegate)
delegate
- is the ValidationState
to adapt.public ValidationStateMessageCollector(ValidationState delegate, String separator)
delegate
- is the ValidationState
to adapt
.separator
- is the separator
.public String getSeparator()
String
used to separate individual validation
failure
messages
for getFailureMessages()
.public void onFailure(ValidationFailure failure)
ValidationCollector
ValidationFailure
occurred.onFailure
in interface ValidationCollector
onFailure
in class AbstractValidationStateCollector
failure
- is the new ValidationFailure
.public boolean isValid()
AbstractValidationStateCollector
validation
has been
successful.
false
if a ValidationFailure
has been collected
by this instance. It may therefore return true
even if the delegate
would
return false
.isValid
in interface ValidationState
isValid
in class AbstractValidationStateCollector
true
if no ValidationFailure
has been collected
,
false
otherwise.public String getFailureMessages()
failure messages
or null
if valid.Copyright © 2001–2016 mmm-Team. All rights reserved.