public static int atMostOneOf(Object... namesAndValues) {
		int index = -1;
		Assert.state(namesAndValues.length % 2 == 0,
				"Expected even number of arguments: " + Arrays.asList(namesAndValues));
		for (int i = 0; i < namesAndValues.length / 2; i++) {
			Assert.state(namesAndValues[i * 2] instanceof String, "Argument at position " + i
					+ " should be argument name");
			if (namesAndValues[i * 2 + 1] != null && namesAndValues[i * 2 + 1] != Boolean.FALSE) {
				if (index != -1) {
					throw new IllegalArgumentException(String.format("You can't specify both '%s' and '%s'",
							namesAndValues[index * 2], namesAndValues[i * 2]));
				}
				else {
					index = i;
				}
			}
		}
		return index;
	}
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.

@return the index of the "pair" that was not {@code null}, or -1 if none was set
@throws IllegalArgumentException if more than one argument is non null
@throws IllegalStateException if the method is called with wrong values (e.g. non even number of args)
spring-xd-shell/src/main/java/org/springframework/xd/shell/util/Assertions.java