Assert.java 977 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package com.fjhx.utils;
  2. import org.springblade.core.log.exception.ServiceException;
  3. import org.springblade.core.tool.utils.ObjectUtil;
  4. public class Assert {
  5. /**
  6. * 断言不为空
  7. *
  8. * @param obj 参数
  9. * @param errStr 异常提示
  10. */
  11. public static void notEmpty(Object obj, String errStr) {
  12. if (ObjectUtil.isEmpty(obj)) {
  13. throw new ServiceException(errStr);
  14. }
  15. }
  16. /**
  17. * 断言为0
  18. *
  19. * @param integer 参数
  20. * @param errStr 异常提示
  21. */
  22. public static void eqZero(Integer integer, String errStr) {
  23. if (integer != 0) {
  24. throw new ServiceException(errStr);
  25. }
  26. }
  27. /**
  28. * 断言为真
  29. *
  30. * @param flag 参数
  31. * @param errStr 异常提示
  32. */
  33. public static void eqTrue(Boolean flag, String errStr) {
  34. if (flag == null || flag.equals(false)) {
  35. throw new ServiceException(errStr);
  36. }
  37. }
  38. }