|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.smartics.properties.tutorial.property.constraints.PropertyConstraintsTutorial
@Document(title="Property Constraints", sortKey="basics0050") @DocCategory(value="basics") public class PropertyConstraintsTutorial
This tutorial introduces how to add constraints to the property declaration.
This feature takes the burden of validation from the developers shoulders. It is based on Beans Validation (JSR-303), so any constraint defined with this technology can be used for validating properties.
Constructor Summary | |
---|---|
PropertyConstraintsTutorial() |
Method Summary | |
---|---|
void |
invalidEnumValuedProperty() The following examples shows that setting the property to an invalid value throws an exception on validation. |
void |
invalidRangedValueProperty() The following examples shows that setting the property to an invalid value throws an exception on validation. |
void |
mandatoryAndOptionalProperties() Per default all properties are optional. |
void |
noValidationAtAppend() Any property value - valid or not - may be added at any time. |
void |
propertyWithAEnumValue() To specify a a property with a value from an enumeration, use an enum return type. |
void |
propertyWithARangeValue() To specify a a property with a value from a range, use PropertyIntValueRange . |
void |
setUp() |
void |
validateMethod() To check is a configuration is valid, the ConfigurationProperties.validate() has to be called. |
void |
validationOnAccess() But as soon as it is accessed, it is guaranteed to be validated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PropertyConstraintsTutorial()
Method Detail |
---|
public void setUp()
@DocSection public void validateMethod()
To check is a configuration is valid, the ConfigurationProperties.validate()
has to be called.
@DocChapter public void mandatoryAndOptionalProperties()
Per default all properties are optional. To mark a property as required use either NotNull
or NotBlank
.
@DocChapter public void propertyWithARangeValue()
To specify a a property with a value from a range, use PropertyIntValueRange
.
@DocChapter public void invalidRangedValueProperty()
The following examples shows that setting the property to an invalid value throws an exception on validation.
@DocChapter public void propertyWithAEnumValue()
To specify a a property with a value from an enumeration, use an enum return type.
@DocChapter public void invalidEnumValuedProperty()
The following examples shows that setting the property to an invalid value throws an exception on validation.
@DocSection public void noValidationAtAppend()
Any property value - valid or not - may be added at any time.
@DocSection public void validationOnAccess()
But as soon as it is accessed, it is guaranteed to be validated.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |