MCPcopy Create free account
hub / github.com/jmrozanec/cron-utils / map

Method map

src/main/java/com/cronutils/mapper/CronMapper.java:76–95  ·  view source on GitHub ↗

Maps given cron to target cron definition. @param cron - Instance to be mapped; if null a NullPointerException will be raised @return new Cron instance, never null;

(final Cron cron)

Source from the content-addressed store, hash-verified

74 * @return new Cron instance, never null;
75 */
76 public Cron map(final Cron cron) {
77 Preconditions.checkNotNull(cron, "Cron must not be null");
78 if(cron instanceof RebootCron){
79 if(this.to.getCronNicknames().contains(CronNicknames.REBOOT)){
80 return new RebootCron(this.to);
81 } else {
82 throw new IllegalArgumentException("The target cron definition does not support @reboot nickname");
83 }
84 }
85 final List<CronField> fields = new ArrayList<>();
86 for (final CronFieldName name : CronFieldName.values()) {
87 if (mappings.containsKey(name)) {
88 final CronField field = mappings.get(name).apply(cron.retrieve(name));
89 if (field != null) {
90 fields.add(field);
91 }
92 }
93 }
94 return cronRules.apply(new SingleCron(to, fields)).validate();
95 }
96
97 /**
98 * Creates a CronMapper that maps a cron4j expression to a quartz expression.

Calls 5

checkNotNullMethod · 0.95
getCronNicknamesMethod · 0.80
applyMethod · 0.65
retrieveMethod · 0.65
validateMethod · 0.65