StringOperations.java 775 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package com.ydtech.utils;
  2. import com.ydtech.exception.SystemException;
  3. /**
  4. * @version
  5. * @description: 业务中字符串处理
  6. * @author: wenks
  7. * @date: 2024/6/6 10:15
  8. **/
  9. public class StringOperations {
  10. private StringOperations() {
  11. throw new IllegalStateException("Utility class");
  12. }
  13. /**
  14. * 将空字符串和null 都处理为null
  15. * @param s 字符
  16. * @return
  17. */
  18. public static String emptyStringToNull(String s){
  19. return StringUtils.isEmpty(s) ? null : s;
  20. }
  21. /**
  22. * 字符串为空报错
  23. * @param s 字符
  24. * @return
  25. */
  26. public static void nullException(String s, String message){
  27. if (StringUtils.isEmpty(s)) {
  28. throw new SystemException(message);
  29. }
  30. }
  31. }