java.lang.Object
org.springframework.cloud.dataflow.shell.command.Assertions

public class Assertions extends Object
Various utility methods when dealing with shell commands.
Author:
Eric Bottard
  • Method Details

    • exactlyOneOf

      public static int exactlyOneOf(Object... namesAndValues)
      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 null
      IllegalArgumentException - if the method is called with invalid values (e.g. non even number of args)
    • atMostOneOf

      public static int atMostOneOf(Object... namesAndValues)
      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 null
      IllegalArgumentException - if the method is called with invalid values (e.g. non even number of args)