AssertionUtils.java 930 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package com.ydtech.modules.protocol.utils;
  2. import com.ydtech.exception.SystemException;
  3. import org.apache.commons.lang3.StringUtils;
  4. import org.springframework.util.ObjectUtils;
  5. /**
  6. * 断言工具类
  7. *
  8. * @author wenks
  9. */
  10. public class AssertionUtils {
  11. private AssertionUtils() {
  12. throw new IllegalStateException("AssertionUtils class");
  13. }
  14. private static void assertion(boolean b, String message) {
  15. if (b) throw new SystemException(message);
  16. }
  17. public static void isSucceed(int b, String message) {
  18. assertion(b <= 0, message);
  19. }
  20. public static void isSucceed(boolean b, String message) {
  21. assertion(!b, message);
  22. }
  23. public static void isEmpty(Object o, String message) {
  24. assertion(ObjectUtils.isEmpty(o), message);
  25. }
  26. public static void isStringEmpty(String s, String message) {
  27. assertion(StringUtils.isEmpty(s), message);
  28. }
  29. }