LocalAssert.java 1012 B

1234567891011121314151617181920212223242526272829303132333435
  1. package com.rf.fileCrack.utils;
  2. import com.alibaba.druid.util.StringUtils;
  3. import java.util.Collection;
  4. /**
  5. * @Description:断言工具类
  6. * @Author: mimang
  7. * @Date: 2024/9/6
  8. */
  9. public abstract class LocalAssert {
  10. public static void isTrue(boolean expression, String message) throws RuntimeException {
  11. if (!expression) {
  12. throw new RuntimeException(message);
  13. }
  14. }
  15. public static void isStringEmpty(String param, String message) throws RuntimeException{
  16. if(StringUtils.isEmpty(param)) {
  17. throw new RuntimeException(message);
  18. }
  19. }
  20. public static void isObjectEmpty(Object object, String message) throws RuntimeException {
  21. if (object == null) {
  22. throw new RuntimeException(message);
  23. }
  24. }
  25. public static void isCollectionEmpty(Collection coll, String message) throws RuntimeException {
  26. if (coll == null || (coll.size() == 0)) {
  27. throw new RuntimeException(message);
  28. }
  29. }
  30. }