Class PrerequisiteChecker
- java.lang.Object
-
- de.julielab.java.utilities.prerequisites.PrerequisiteChecker
-
public class PrerequisiteChecker extends Object
This is a class meant for chaining together calls likePrerequisiteChecker.checkThat().notNull(ob1, ob2).notEmpty(coll).withNames("ob1", "ob2", "coll").execute(). In case that any of the checks fail onexecute(), a message will be recorded for each failed check. Then, anIllegalArgumentExceptionis thrown explaining what went wrong.
-
-
Field Summary
Fields Modifier and Type Field Description static StringPREREQUISITE_CHECKS_ENABLED
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PrerequisiteCheckercheckThat()voidexecute()Checks for null items and, if found, generates an error message.PrerequisiteCheckernotEmpty(Collection<?>... collections)PrerequisiteCheckernotNull(Object... objects)PrerequisiteCheckersupplyNotEmpty(Supplier<Collection<?>>... collections)PrerequisiteCheckersupplyNotNull(Supplier<?>... objectSuppliers)PrerequisiteCheckerwithNames(String... names)Sets the names for all items previously added to the checker, possibly in multiple calls.
-
-
-
Field Detail
-
PREREQUISITE_CHECKS_ENABLED
public static final String PREREQUISITE_CHECKS_ENABLED
- See Also:
- Constant Field Values
-
-
Method Detail
-
checkThat
public static PrerequisiteChecker checkThat()
-
withNames
public PrerequisiteChecker withNames(String... names)
Sets the names for all items previously added to the checker, possibly in multiple calls. The number of names may lower or even higher than the number of given items. In the first case, the names will be assigned to the checked items from left to right in a continuous manner while the remaining items will receive null as their name. In the second case, all superfluous names will simply be ignored.- Parameters:
names- The names to give to the last list of items to check- Returns:
- This object for chaining.
-
notNull
public PrerequisiteChecker notNull(Object... objects)
-
notEmpty
public PrerequisiteChecker notEmpty(Collection<?>... collections)
-
supplyNotEmpty
public PrerequisiteChecker supplyNotEmpty(Supplier<Collection<?>>... collections)
-
supplyNotNull
public PrerequisiteChecker supplyNotNull(Supplier<?>... objectSuppliers)
-
execute
public void execute()
Checks for null items and, if found, generates an error message.
-
-