All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lone.common.util.ExceptionUtils Maven / Gradle / Ivy

The newest version!
package com.lone.common.util;

import com.lone.common.exception.BusinessException;

public class ExceptionUtils {

	private ExceptionUtils(){
	}
	
	
	/**
	 * 如果目标为空则抛出异常
	 * @param target
	 * @param errorMessage
	 */
	public static void throwIfNull(Object target,String errorMessage){
		if(target==null){
			throw new BusinessException(errorMessage);
		}
	}
	
	/**
	 * 如果目标为空则抛出异常
	 * 本方法空指针安全
	 * 2009-11-3
	 * @param target
	 * @param errorMessage
	 */
	public static void throwIfEmpty(String target,String errorMessage)
	{
		if(target==null || target.equals("")){
			throw new BusinessException(errorMessage);
		}
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy