Contracts

Description

Contracts is a invocation validation framework for Java interfaces. It follows the principle of Design by contract via Java interface annotations.

Contracts provides basic integration to Spring and Guice based Dependency injection usage.

The JSR-305 effort is similar, and JSR-305 annotations will be used instead of proprietary ones in coming releases.

Examples

Example :

@Contracts
public interface SomeService {
  
    void mandatoryArgs(Object arg1, Object arg2);

    void nonEmptArg(@NotEmpty arg);

    void optionalArg(@Optional arg);
    
    @NotEmpty
    List nonEmptyReturn();

    @Optional
    Object optionalReturn();

    @Require("!args.isEmpty()") // not yet implemented
    void methodWithPrecondition(List args);

    @Ensure("return != null") // not yet implemented
    Object methodWithPostCondition();

}

Bookmark with: del.icio.us   digg   Mister Wong   YahooMyWeb   Reddit   Furl   Spurl   blogmarks

In a nutshell

Name Contracts
Most Recent Version 0.1.5
Javadocs coming soon
State Beta
License LGPL v2.1
Version Control on Mysema Source
Maven repo on Mysema Source
Issue Management none
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.