Here you can find the source of validateCondition(boolean condition, String messageFormat, Object... messageArgs)
Parameter | Description |
---|---|
condition | The condition to validate |
messageFormat | The java.util.Formatter format string of the message to be passed to the exception that is thrown if validation fails |
messageArgs | The substitution arguments for the format string |
Parameter | Description |
---|---|
IllegalArgumentException | If the validation fails |
public static void validateCondition(boolean condition, String messageFormat, Object... messageArgs)
//package com.java2s; /******************************************************************************* * Copyright 2012 Eric McIntyre//from www. j av a 2 s .c o m * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ public class Main { /** * Validates that a condition is {@code true}. Useful for general and concise comparisons. * * @param condition * The condition to validate * @param messageFormat * The {@linkplain java.util.Formatter format string} of the message to be passed to the exception that * is thrown if validation fails * @param messageArgs * The substitution arguments for the format string * @throws IllegalArgumentException * If the validation fails */ public static void validateCondition(boolean condition, String messageFormat, Object... messageArgs) { if (!condition) { throw new IllegalArgumentException(String.format(messageFormat, messageArgs)); } } }