Skip to content
Emil Forslund edited this page Oct 20, 2016 · 2 revisions

Speedment - Common - Invariant

Utility classes for making sure a methods invariant is met and otherwise throw exceptions. This is an addition to the Objects.requireNonNull-method that was added in Java 8, for an example to check multiple parameters in one call.

Example Usage

import static com.speedment.common.invariant.NullUtil;

public final class VectorProperty {

    private final AtomicDouble x, y;

    public VectorProperty(AtomicDouble x, AtomicDouble y) {
        requireNonNulls(x, y); // Check two parameters in the same call
        this.x = x;
        this.y = y;
    }

    ...
}

Maven

To use Invariant in your own projects, add the following to your pom.xml-file.

<dependency>
    <groupId>com.speedment.common</groupId>
    <artifactId>invariant</artifactId>
    <version>1.0.0</version>
</dependency>