Insist is a framework for enforcing value invariants using a fluent API and hamcrest matchers.
import static io.github.jabau.insist.Insistence.insist;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.Matchers.notNullValue;
class Example {
final String name;
Example(String name) {
this.name = insist("name", name)
.is(notNullValue())
.value();
}
Integer squareIfInteger(Object x) {
insist(x).is(notNullValue()).is(instanceOf(Integer.class));
final Integer i = (Integer) x;
return i*i;
}
}
For building the library you need:
mvn install
See the CHANGELOG file.
Released under the MIT License. See the LICENSE file.