Class Assertions
java.lang.Object
org.springframework.cloud.dataflow.shell.command.Assertions
Various utility methods when dealing with shell commands.
- Author:
- Eric Bottard
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
atMostOneOf
(Object... namesAndValues) Accepts 2*N arguments, even ones being names and odd ones being values for those names.static int
exactlyOneOf
(Object... namesAndValues) Accepts 2*N arguments, even ones being names and odd ones being values for those names.
-
Method Details
-
exactlyOneOf
Accepts 2*N arguments, even ones being names and odd ones being values for those names. Asserts that exactly only one value is non null (or non-false, Boolean.FALSE being treated as false), or throws an exception with a descriptive message otherwise.- Parameters:
namesAndValues
- the list of names and values- Returns:
- the index of the "pair" that was not
null
- Throws:
IllegalStateException
- if more than one argument is non nullIllegalArgumentException
- if the method is called with invalid values (e.g. non even number of args)
-
atMostOneOf
Accepts 2*N arguments, even ones being names and odd ones being values for those names. Asserts that at most one value is non null (or non-false, Boolean.FALSE being treated as false), or throws an exception with a descriptive message otherwise.- Parameters:
namesAndValues
- the list of names and values- Returns:
- the index of the "pair" that was not
null
, or -1 if none was set - Throws:
IllegalStateException
- if more than one argument is non nullIllegalArgumentException
- if the method is called with invalid values (e.g. non even number of args)
-