EmailCron.java 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.simuwang.base.common.enums;
  2. import java.util.stream.Stream;
  3. /**
  4. * FileName: EMAIL_CRON
  5. * Author: chenjianhua
  6. * Date: 2024/9/9 13:50
  7. * Description: ${DESCRIPTION}
  8. */
  9. public enum EmailCron {
  10. EVERY_HOUR(1, "0/1 0 * * * ?"), ONE_AM(2, "0 0 1 * * ?");
  11. private final Integer text;
  12. private final String cron;
  13. EmailCron(Integer text, String cron)
  14. {
  15. this.text = text;
  16. this.cron = cron;
  17. }
  18. public static EmailCron getEmailCronByText(Integer text) {
  19. if (null == text){
  20. return null;
  21. }
  22. for(EmailCron s : EmailCron.values()){
  23. if(text.equals(s.getText())){
  24. return s;
  25. }
  26. }
  27. return null;
  28. }
  29. public static EmailCron getEmailCronByCron(String cron) {
  30. return Stream.of(EmailCron.values()).filter(e -> e.cron.equals(cron)).findFirst().orElse(null);
  31. }
  32. public Integer getText()
  33. {
  34. return text;
  35. }
  36. public String getCron()
  37. {
  38. return cron;
  39. }
  40. }