All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.yetamine.checks.package-info Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
/**
 * Utility classes for easy runtime condition checks.
 *
 * 

Overview

* * Using classes from this package can make pre-condition checks more compact * and readable when employing lambdas than usual if-then-throw code pattern: * *
 * public void foo(int i) {
 *     // Following check throws IllegalArgumentException if not satisfied with the detailed message
 *     bar(Argument.check(i, i > 0, () -> String.format("Requiring a positive number (given: %d).", i)));
 * }
 *
 * private void bar(int i) {
 *     assert (i > 0);
 *     // Doing some stuff, requiring 'i' to be positive. But this method is private
 *     // and therefore it relies on the callers to provide already checked values.
 * }
 * 
* *

* To make the checks cheaper, the exception suppliers are not checked whether * not being {@code null}; all such cases are guarded with {@code assert}, so * that code defects could be still detected in a testing environment. */ package net.yetamine.checks;





© 2015 - 2025 Weber Informatics LLC | Privacy Policy