class CrawlingService extends AbstractScheduledService { @Override protected void runOneIteration() throws Exception { //run this alot } @Override protected void startUp() throws Exception { //anything you need to step up } @Override protected void shutDown() throws Exception { //anything you need to tear down } @Override protected Scheduler scheduler() { return new CustomScheduler() { @Override protected Schedule getNextSchedule() throws Exception { long a = 1000; //number you can randomize to your heart's content return new Schedule(a, TimeUnit.MILLISECONDS); } }; } }
/** * Gets the unadjusted end date. * <p> * The end date before any business day adjustment. * * @return the unadjusted schedule end date */ public LocalDate getUnadjustedEndDate() { return getLastPeriod().getUnadjustedEndDate(); }
/** * Gets the start date of the schedule. * <p> * The first date in the schedule, typically treated as inclusive. * If the schedule adjusts for business days, then this is the adjusted date. * * @return the schedule start date */ @Override public LocalDate getStartDate() { return getFirstPeriod().getStartDate(); }
private PeriodicSchedule createDates(LocalDate start, LocalDate end, LocalDate first, LocalDate last) { return PeriodicSchedule.builder() .startDate(start) .endDate(end) .frequency(P1M) .businessDayAdjustment(BDA) .firstRegularStartDate(first) .lastRegularEndDate(last) .build(); }
public void test_subSchedule_2monthIn3Month_shortInitial() { SchedulePeriod test = SchedulePeriod.of(JUN_17, SEP_17); Schedule schedule = test.subSchedule(P2M, RollConventions.DAY_17, StubConvention.SHORT_INITIAL, BusinessDayAdjustment.NONE) .createSchedule(REF_DATA); assertEquals(schedule.size(), 2); assertEquals(schedule.getPeriod(0), SchedulePeriod.of(JUN_17, JUL_17)); assertEquals(schedule.getPeriod(1), SchedulePeriod.of(JUL_17, SEP_17)); assertEquals(schedule.getFrequency(), P2M); assertEquals(schedule.getRollConvention(), RollConventions.DAY_17); }
public void test_subSchedule_3monthIn3Month() { SchedulePeriod test = SchedulePeriod.of(JUN_17, SEP_17); Schedule schedule = test.subSchedule(P3M, RollConventions.DAY_17, StubConvention.NONE, BusinessDayAdjustment.NONE) .createSchedule(REF_DATA); assertEquals(schedule.size(), 1); assertEquals(schedule.getPeriod(0), SchedulePeriod.of(JUN_17, SEP_17)); }
public void coverage_builder() { Schedule.Builder builder = Schedule.builder(); builder .periods(P1_STUB) .frequency(P1M) .rollConvention(DAY_17) .build(); }
public void coverage_builder() { SchedulePeriod.Builder builder = SchedulePeriod.builder(); builder .startDate(JUL_05) .endDate(JUL_18) .unadjustedStartDate(JUL_04) .unadjustedEndDate(JUL_17) .build(); }
private boolean isInitialStub() { return !isTerm() && !getFirstPeriod().isRegular(frequency, rollConvention); }
private boolean isFinalStub() { return !isSinglePeriod() && !getLastPeriod().isRegular(frequency, rollConvention); }
/** * Gets the end date of the schedule. * <p> * The last date in the schedule, typically treated as exclusive. * If the schedule adjusts for business days, then this is the adjusted date. * * @return the schedule end date */ @Override public LocalDate getEndDate() { return getLastPeriod().getEndDate(); }
/** * Gets the unadjusted start date. * <p> * The start date before any business day adjustment. * * @return the unadjusted schedule start date */ public LocalDate getUnadjustedStartDate() { return getFirstPeriod().getUnadjustedStartDate(); }
/** * Gets the accrual start date of the leg. * <p> * This is the first accrual date in the leg, often known as the effective date. * * @return the start date of the leg */ public AdjustableDate getStartDate() { return paymentSchedule.calculatedStartDate(); }
/** * Checks if this schedule has a single period. * * @return true if this is a single period */ public boolean isSinglePeriod() { return size() == 1; }
private LocalDate calculatedLastRegularEndDate(LocalDate unadjEnd, ReferenceData refData) { if (lastRegularEndDate == null) { return unadjEnd; } if (refData != null && rollConvention != null) { return calculatedUnadjustedDateFromAdjusted(lastRegularEndDate, rollConvention, businessDayAdjustment, refData); } return lastRegularEndDate; }
/** * Returns a builder that allows this bean to be mutated. * @return the mutable builder, not null */ public Builder toBuilder() { return new Builder(this); }
public void test_subSchedule_1monthIn3Month() { SchedulePeriod test = SchedulePeriod.of(JUN_17, SEP_17); Schedule schedule = test.subSchedule(P1M, RollConventions.DAY_17, StubConvention.NONE, BusinessDayAdjustment.NONE) .createSchedule(REF_DATA); assertEquals(schedule.size(), 3); assertEquals(schedule.getPeriod(0), SchedulePeriod.of(JUN_17, JUL_17)); assertEquals(schedule.getPeriod(1), SchedulePeriod.of(JUL_17, AUG_17)); assertEquals(schedule.getPeriod(2), SchedulePeriod.of(AUG_17, SEP_17)); assertEquals(schedule.getFrequency(), P1M); assertEquals(schedule.getRollConvention(), RollConventions.DAY_17); }
/** * Gets the accrual start date of the leg. * <p> * This is the first accrual date in the leg, often known as the effective date. * * @return the start date of the leg */ public AdjustableDate getStartDate() { return paymentSchedule.calculatedStartDate(); }
public void test_subSchedule_2monthIn3Month_shortFinal() { SchedulePeriod test = SchedulePeriod.of(JUN_17, SEP_17); Schedule schedule = test.subSchedule(P2M, RollConventions.DAY_17, StubConvention.SHORT_FINAL, BusinessDayAdjustment.NONE) .createSchedule(REF_DATA); assertEquals(schedule.size(), 2); assertEquals(schedule.getPeriod(0), SchedulePeriod.of(JUN_17, AUG_17)); assertEquals(schedule.getPeriod(1), SchedulePeriod.of(AUG_17, SEP_17)); assertEquals(schedule.getFrequency(), P2M); assertEquals(schedule.getRollConvention(), RollConventions.DAY_17); }