From b90fa49ebc5ae54935f16037b62ea24ba7a1941f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 25 May 2010 14:23:08 +0000 Subject: [PATCH] polishing --- .../scheduling/support/CronTrigger.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/support/CronTrigger.java b/org.springframework.context/src/main/java/org/springframework/scheduling/support/CronTrigger.java index 37477b40fa8..00db7933605 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/support/CronTrigger.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/support/CronTrigger.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,25 +34,27 @@ public class CronTrigger implements Trigger { private final CronSequenceGenerator sequenceGenerator; + /** - * Build a {@link CronTrigger} from the pattern provided. + * Build a {@link CronTrigger} from the pattern provided in the default time zone. * @param cronExpression a space-separated list of time fields, * following cron expression conventions - * @param timeZone a time zone in which the trigger times will be generated */ - public CronTrigger(String cronExpression, TimeZone timeZone) { - this.sequenceGenerator = new CronSequenceGenerator(cronExpression, timeZone); + public CronTrigger(String cronExpression) { + this(cronExpression, TimeZone.getDefault()); } /** - * Build a {@link CronTrigger} from the pattern provided in the default time zone. + * Build a {@link CronTrigger} from the pattern provided. * @param cronExpression a space-separated list of time fields, * following cron expression conventions + * @param timeZone a time zone in which the trigger times will be generated */ - public CronTrigger(String cronExpression) { - this(cronExpression, TimeZone.getDefault()); + public CronTrigger(String cronExpression, TimeZone timeZone) { + this.sequenceGenerator = new CronSequenceGenerator(cronExpression, timeZone); } + public Date nextExecutionTime(TriggerContext triggerContext) { Date date = triggerContext.lastCompletionTime(); if (date == null) { @@ -61,10 +63,11 @@ public class CronTrigger implements Trigger { return this.sequenceGenerator.next(date); } + @Override public boolean equals(Object obj) { - return (this == obj || (obj instanceof CronTrigger && this.sequenceGenerator - .equals(((CronTrigger) obj).sequenceGenerator))); + return (this == obj || (obj instanceof CronTrigger && + this.sequenceGenerator.equals(((CronTrigger) obj).sequenceGenerator))); } @Override