de.smartics.properties.tutorial.property.constraints
Class PropertyConstraintsTutorial

Package class diagram package PropertyConstraintsTutorial
java.lang.Object
  extended by de.smartics.properties.tutorial.property.constraints.PropertyConstraintsTutorial

@Document(title="Property Constraints",
          sortKey="basics0050")
@DocCategory(value="basics")
public class PropertyConstraintsTutorial
     
     
extends Object

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

PropertyConstraintsTutorial

public PropertyConstraintsTutorial()
Method Detail

setUp

public void setUp()

validateMethod

@DocSection
public void validateMethod()

To check is a configuration is valid, the ConfigurationProperties.validate() has to be called.


mandatoryAndOptionalProperties

@DocChapter
public void mandatoryAndOptionalProperties()

Per default all properties are optional. To mark a property as required use either NotNull or NotBlank.


propertyWithARangeValue

@DocChapter
public void propertyWithARangeValue()

To specify a a property with a value from a range, use PropertyIntValueRange.


invalidRangedValueProperty

@DocChapter
public void invalidRangedValueProperty()

The following examples shows that setting the property to an invalid value throws an exception on validation.


propertyWithAEnumValue

@DocChapter
public void propertyWithAEnumValue()

To specify a a property with a value from an enumeration, use an enum return type.


invalidEnumValuedProperty

@DocChapter
public void invalidEnumValuedProperty()

The following examples shows that setting the property to an invalid value throws an exception on validation.


noValidationAtAppend

@DocSection
public void noValidationAtAppend()

Any property value - valid or not - may be added at any time.


validationOnAccess

@DocSection
public void validationOnAccess()

But as soon as it is accessed, it is guaranteed to be validated.



Copyright © 2012-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.