VALUE
- is the generic type of the value
.public abstract class AbstractUiFeatureValueAndValidation<VALUE> extends Object implements UiFeatureValueAndValidation<VALUE>
UiFeatureValueAndValidation
.Constructor and Description |
---|
AbstractUiFeatureValueAndValidation()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addValidatorMandatory()
This is a convenience method for adding the most common validator
ValidatorMandatory . |
protected void |
clearValidity()
This method may clear potential state information from previous validations.
|
protected ValidationFailure |
createValidationFailure(Throwable error)
This method converts an exception from
getValueOrException(Object) to a
ValidationFailure . |
protected abstract org.slf4j.Logger |
getLogger() |
protected abstract String |
getSource() |
VALUE |
getValue()
This method gets the value of this object.
|
VALUE |
getValueAndValidate(ValidationState state)
This method is a combination of
AttributeReadValueAdvanced.getValue() and AbstractValidatableObject.validate(ValidationState) . |
VALUE |
getValueOrException(VALUE template)
This method is like
AttributeReadValueAdvanced.getValue() but does NOT catch exceptions while parsing the value from the
user input. |
protected void |
handleGetValueError(RuntimeException e,
ValidationState state)
This method handles a
RuntimeException that occurred in
UiFeatureValueAndValidation.getValueDirect(Object, ValidationState) . |
void |
resetValue()
This method resets this widget.
|
void |
setValue(VALUE value)
This method sets the
value . |
void |
setValueForUser(VALUE value)
This method is like
AttributeWriteValueAdvanced.setValue(Object) but will NOT set the original
value and will set the modified to true (instead
of false ). |
String |
toString() |
boolean |
validate(ValidationState state)
This method performs the actual validation.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getValueDirect
addChangeHandler, removeChangeHandler
setValue
getOriginalValue
isMandatory
addValidator, removeValidator
public AbstractUiFeatureValueAndValidation()
protected abstract org.slf4j.Logger getLogger()
Logger
instance.public final void setValue(VALUE value)
setValue
in interface AttributeWriteValueAdvanced<VALUE>
setValue
in interface AttributeWriteValue<VALUE>
value
- is the new value
. May be null
unless otherwise stated.public final void setValueForUser(VALUE value)
AttributeWriteValueAdvanced.setValue(Object)
but will NOT set the original
value
and will set the modified
to true
(instead
of false
).setValueForUser
in interface AttributeWriteValueAdvanced<VALUE>
value
- is the value
to set.public final VALUE getValue()
null
instead. If you want to do validation and give feedback to the
user please use AttributeReadValueAdvanced.getValueOrException(Object)
instead. However, there are higher-level ways to do
this such as
getValueAndValidate
.getValue
in interface AttributeReadValueAdvanced<VALUE>
getValue
in interface AttributeReadValue<VALUE>
null
unless otherwise stated.protected void handleGetValueError(RuntimeException e, ValidationState state)
RuntimeException
that occurred in
UiFeatureValueAndValidation.getValueDirect(Object, ValidationState)
.e
- is the RuntimeException
to handle.state
- is the ValidationState
or null
if no validation is performed.public VALUE getValueOrException(VALUE template) throws RuntimeException
AttributeReadValueAdvanced.getValue()
but does NOT catch exceptions while parsing the value from the
user input. Additionally it allows to provide a template object that gets populated. This allows advanced
features with polymorphism as you can also provide a sub-class of <VALUE>.getValueOrException
in interface AttributeReadValueAdvanced<VALUE>
template
- is the object where the data is filled in. May also be null
- then this
method will create a new instance.null
if empty. If the value type is
String
the empty String
has to be returned if no value has been entered. In case
<VALUE> is a mutable object (java bean) and template
is NOT null
,
this method is supposed to return template
.RuntimeException
- if the entered value is invalid (e.g. paring caused a
NumberFormatException
).public final VALUE getValueAndValidate(ValidationState state)
AttributeReadValueAdvanced.getValue()
and AbstractValidatableObject.validate(ValidationState)
. It is
designed for API users implementing higher level dialog logic and is therefore easy to use. It performs a
validation
and only on success it returns the value
. null
is not a valid value. Never call this method with
null
as argument if <VALUE> is Void
or anything else that considers
null
as a valid value. It should be used for high-level UI nodes such as entire input forms
or (sub-)dialogs.getValueAndValidate
in interface UiFeatureValueAndValidation<VALUE>
state
- is the ValidationState
. Shall initially be created as new instance and passed on in
case of recursive validations. May also be null
and will then be created internally
(in case you do not need the validation result).value
or null
if the
validation
failed or null
is the actual (valid)
value.public final void resetValue()
setValue
(AttributeReadValueAdvanced.getOriginalValue()
)
resetValue
in interface AttributeWriteValueAdvanced<VALUE>
public void addValidatorMandatory()
ValidatorMandatory
.addValidatorMandatory
in interface UiFeatureValidation<VALUE>
public final boolean validate(ValidationState state)
validate
in interface AbstractValidatableObject
state
- is the ValidationState
. Shall initially be created as new instance and passed on in case of
recursive validations. May also be null
and will then be created internally (in case you do not need
more feedback than a boolean result).true
if the validation of this object has been successful, false
otherwise (if there are
validation failures).protected void clearValidity()
protected ValidationFailure createValidationFailure(Throwable error)
getValueOrException(Object)
to a
ValidationFailure
.error
- is the exception.ValidationFailure
.protected abstract String getSource()
Copyright © 2001–2016 mmm-Team. All rights reserved.