Java Assert Not Null assertNotNullNotEmpty(String obj, String paramName)

Here you can find the source of assertNotNullNotEmpty(String obj, String paramName)

Description

assert Not Null Not Empty

License

Open Source License

Declaration

public static void assertNotNullNotEmpty(String obj, String paramName) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *  This file is part of free utilities created by Joga Singh <joga.singh@gmail.com>.
 *  You are free to copy/modify/distribute the files to use it in any way you like.
 *  However as a credit, author's name should be mentioned in the file header.
 *  /*from w  w w.j av  a2  s .  co  m*/
 *  See the complete license terms (MIT License) in LICENSE.TXT included in the package.
 *  
 *******************************************************************************/

public class Main {
    public static void assertNotNullNotEmpty(String obj, String paramName) {
        assertNotNull(obj, paramName);
        if (obj.isEmpty()) {
            throw new IllegalArgumentException(paramName + " cannot be empty");
        }
    }

    public static void assertNotNull(Object obj, String paramName) {
        if (obj == null) {
            throw new IllegalArgumentException(paramName + " cannot be null");
        }
    }
}

Related

  1. assertNotNull(T object, String fieldName)
  2. assertNotNull(T value, String message)
  3. assertNotNullArg(Object value, String argName)
  4. assertNotNullArgument(Object obj, String argName)
  5. assertNotNullEightBytes(byte[] bytes)
  6. assertNotNullOrThrowException(final Object... objects)
  7. assertObjectNotNull(final Object object)
  8. assertObjectNotNull(Object o, String name)
  9. assertObjectNotNull(String variableName, Object value)