Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.cantaa.util;

Checks for several purposes like parameters for methods etc.

Author(s):
Hans Lesmeister
 
 public class Reject
 {

   
Throws an IllegalStateException if the passed expression is true

Parameters:
expression to evaluate
msg The message to pass on to the exception
   public static void ifTrue(boolean expressionString msg) {
      if (expression) {
         throw new IllegalStateException(msg);
      }
   }

   
Throws an IllegalStateException if the passed expression is false

Parameters:
expression to evaluate
msg The message to pass on to the exception
   public static void ifFalse(boolean expressionString msg) {
      if (!expression) {
         throw new IllegalStateException(msg);
      }
   }

   
Throws an IllegalArgumentException if the passed object is null

Parameters:
object parameter to check
message The message to pass on to the exception
Throws:
java.lang.IllegalArgumentException if the passed object is null
   public static void ifNull(Object objectString message) {
      if (object == null) {
         throw new IllegalArgumentException(message);
      }
   }
New to GrepCode? Check out our FAQ X