Invariant
Emil Forslund edited this page Oct 20, 2016
·
2 revisions
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.
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;
}
...
}
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>
Speedment is available under the Apache 2 license.
Want to learn more about the enterprise version? Visit www.speedment.com!