Class Validate


  • public class Validate
    extends Object
    • Constructor Detail

      • Validate

        public Validate()
    • Method Detail

      • isTrue

        public static void isTrue​(boolean expression,
                                  String message)

        Validate that the argument condition is true; otherwise throwing an exception with the specified message. This method is useful when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

         Validate.isTrue( (i > 0), "The value must be greater than zero");
         Validate.isTrue( myObject.isOk(), "The object is not OK");
         
        Parameters:
        expression - the boolean expression to check
        message - the exception message if invalid
        Throws:
        IllegalArgumentException - if expression is false