This project has retired. For details please refer to its Attic page.
Constraints
Polygene™
Introduction
Tutorials
Javadoc
Samples
Core
Libraries
Extensions
Tools
Glossary 

Constraints

code

docs

tests

The Constraints library provide a bunch of often used Constraints based on the Polygene™ Constraints api described in Constraint.

Remember that you are not limited to constraints presents in this library, you are encouraged to write your own constraints. See Create a Constraint or take a look at this library source code to learn how to write your own.

Table 25. Artifact

Group IDArtifact IDVersion

org.apache.polygene.libraries

org.apache.polygene.library.constraints

0


Usage

You can use theses constraints on Properties or on method arguments. Here are some examples:

import org.apache.polygene.library.constraints.annotation.*;
  [...snip...]

@Contains( "foo" ) Property<String> containsString();

@Email Property<String> email();

@URL Property<String> url();

@URI Property<String> uri();

@GreaterThan( 10 ) Property<Integer> greaterThan();

@InstanceOf( List.class ) Property<Collection> instanceOf();

@LessThan( 10 ) Property<Integer> lessThan();

@Matches( "a*b*c*" ) Property<String> matches();

@MaxLength( 3 ) Property<String> maxLength();

@MinLength( 3 ) Property<String> minLength();

@NotEmpty Property<String> notEmptyString();

@NotEmpty Property<Collection> notEmptyCollection();

@NotEmpty Property<List> notEmptyList();

@Range( min = 0, max = 100 ) Property<Integer> range();

@OneOf( { "Bar", "Xyzzy" } ) Property<String> oneOf();

void testParameters( @GreaterThan( 10 ) Integer greaterThan );