Project icon

com.io7m.jaffirm

Build status Maven Central Codacy Codecov

The jaffirm package provides simple and fast pre/postcondition and invariant checking functions.

Contents

Features

  • Static invocation, zero-allocation code paths for the common case of non-failing contracts
  • Specialized and generic variants of all functions for use in low-latency software
  • Detailed contract failure messages by construction
  • Written in pure Java 9
  • 100% automated unit test coverage
  • OSGi-ready
  • ISC license

Example

 0,      i -> "Input " + i + " must be > 0");
  checkPreconditionI(x, x % 2 == 0, i -> "Input " + i + " must be even");
  return x * 2;
}

int exampleMultis(final int x)
{
  checkPreconditionsI(
    x,
    conditionI(i -> i > 0,      i -> "Input " + i + " must be > 0"),
    conditionI(i -> i % 2 == 0, i -> "Input " + i + " must be even"));
  return x * 2;
}

> exampleSingles(0)
Exception in thread "main" com.io7m.jaffirm.core.PreconditionViolationException: Precondition violation.
  Received: 0
  Violated conditions:
    [0]: Input 0 must be > 0

> exampleSingles(1)
Exception in thread "main" com.io7m.jaffirm.core.PreconditionViolationException: Precondition violation.
  Received: 1
  Violated conditions:
    [0]: Input 1 must be even

> exampleMultis(-1)
Exception in thread "main" com.io7m.jaffirm.core.PreconditionViolationException: Precondition violation.
  Received: -1
  Violated conditions:
    [0]: Input -1 must be > 0
    [1]: Input -1 must be even

]]>

Releases

The current release is 3.0.0-SNAPSHOT.

Source code and binaries are available from the repository.

Documentation

Documentation for the 3.0.0-SNAPSHOT release is available for reading online.

Documentation for current and older releases is archived in the repository.

User documentation

Maven

The following is a complete list of the project's modules expressed as Maven dependencies:

<dependency>
  <groupId>com.io7m.jaffirm</groupId>
  <artifactId>com.io7m.jaffirm</artifactId>
  <version>3.0.0-SNAPSHOT</version>
</dependency>

<dependency>
  <groupId>com.io7m.jaffirm</groupId>
  <artifactId>com.io7m.jaffirm.core</artifactId>
  <version>3.0.0-SNAPSHOT</version>
</dependency>

<dependency>
  <groupId>com.io7m.jaffirm</groupId>
  <artifactId>com.io7m.jaffirm.documentation</artifactId>
  <version>3.0.0-SNAPSHOT</version>
</dependency>

<dependency>
  <groupId>com.io7m.jaffirm</groupId>
  <artifactId>com.io7m.jaffirm.tests</artifactId>
  <version>3.0.0-SNAPSHOT</version>
</dependency>

Each release of the project is made available on Maven Central within ten minutes of the release announcement.

Changes

Subscribe to the releases atom feed.

2018-05-17 Release: com.io7m.jaffirm 3.0.0
2018-05-17 Change: (Backwards incompatible) Remove checkstyle module and use common checkstyle rules
2018-05-17 Change: Use newest primogenitor
2017-11-04 Release: com.io7m.jaffirm 2.0.0
2017-11-04 Change: (Backwards incompatible) Require JDK 9 and publish a Java 9 module.
2017-11-04 Change: (Backwards incompatible) Remove com.io7m.jnull dependency.
2017-04-07 Release: com.io7m.jaffirm 1.1.0
2017-04-07 Change: Add variadic preconditions/postconditions/invariants. (tickets: 3 )
2017-04-05 Release: com.io7m.jaffirm 1.0.1
2017-04-05 Change: Rename project. Use the new primogenitor POM and 2017 project conventions. Move documentation to kstructural.
2017-02-22 Release: com.io7m.jaffirm 1.0.0
2017-02-22 Change: Initial API-stable release.
2016-08-26 Release: com.io7m.jaffirm 0.1.0
2016-08-26 Change: Initial release.

Sources

This project uses Git to manage source code.

Repository: https://github.com/io7m/jaffirm

$ git clone https://github.com/io7m/jaffirm

License

Copyright ⓒ 2018 Mark Raynsford <code@io7m.com> http://io7m.com

Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.

Bug Tracker

The project uses GitHub Issues to track issues.