Skip to content

WPS/common-contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

132 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WPS common contracts

This project contains a set of contracts for design by contract. The contracts follow the following naming scheme:

  • Methods starting with require are preconditions, which are used to check arguments
  • Methods starting with check are state checks or invariants, which are used to check intermediate results for consistency
  • Methods starting with ensure are postconditions, which are used to check results before returning them

The contracts

The (static) methods implementing different contracts are grouped in the following classes:

  • BaseContracts to test for nullability and simple boolean conditions.
  • CollectionContracts to test collections for nullability and emptiness.
  • StringContracts to test strings for emptiness and blankness (and nullability).
  • NumberContracts to test numbers against bounds ("less than", "less than or equal to", "greater than" and "greater than or equal to") for int, long, float, double and their wrapper types (and nullability).

Maven coordinates

Releases can be found in Maven central under the following coordinates:

<dependency>
    <groupId>de.wps.common</groupId>
    <artifactId>common-contracts</artifactId>
    <version>0.13</version>
</dependency>

If you do not want to get the (only) transitive dependency org.checkerframework:check-qual, you can exclude it:

<dependency>
    <groupId>de.wps.common</groupId>
    <artifactId>common-contracts</artifactId>
    <version>0.13</version>
    <exclusions>
        <exclusion>
            <groupId>org.checkerframework</groupId>
            <artifactId>checker-qual</artifactId>
        </exclusion>
    </exclusions>
</dependency>

About

Java library for checking contracts (preconditions, etc.)

Resources

License

Stars

2 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages