public static NextRelativeTime hourOfDay(Integer hourOfDay) { return new NextRelativeTime(hourOfDay, HOUR_OF_DAY); } public static NextRelativeTime dayOfWeek(Integer dayOfWeek) {
public String toString() { if (HOUR_OF_DAY.equals(indexUnit)) { return "next time it's "+atHour+":"+atMinute; } else if (DAY_OF_WEEK.equals(indexUnit)) { return appendAt("next "+ dayOfWeekToString(index)); } else if (DAY_OF_MONTH.equals(indexUnit)) { return appendAt("next time it's the "+index+"th day of the month"); } return "next unspecified relative time"; }
@Test public void testNextRelativeTime() { assertNull(serializeRelativeTime(NextRelativeTime.hourOfDay(5)).getAtHour()); assertEquals(5, (int) serializeRelativeTime(NextRelativeTime.hourOfDay(5)).getIndex()); assertEquals(NextRelativeTime.HOUR_OF_DAY, serializeRelativeTime(NextRelativeTime.hourOfDay(5)).getIndexUnit()); assertEquals(NextRelativeTime.DAY_OF_WEEK, serializeRelativeTime(NextRelativeTime.dayOfWeek(5)).getIndexUnit()); assertEquals(NextRelativeTime.DAY_OF_MONTH, serializeRelativeTime(NextRelativeTime.dayOfMonth(5)).getIndexUnit()); RelativeTime relativeTime = serializeRelativeTime(NextRelativeTime.dayOfMonth(5) .at(11,45)); assertEquals(11, (int) relativeTime.getAtHour()); assertEquals(45, (int) relativeTime.getAtMinute()); }
@Test public void testNextFirstOfTheMonth() { LocalDateTime base = new LocalDateTime(2015, 12, 28, 9, 0, 0, 0); LocalDateTime absoluteTime = NextRelativeTime .dayOfMonth(1) .resolve(base); assertEquals(new LocalDateTime(2016, 1, 1, 0, 0, 0, 0), absoluteTime); }
@Test public void testNextThursday() { LocalDateTime base = new LocalDateTime(2015, 12, 28, 9, 0, 0, 0); LocalDateTime absoluteTime = NextRelativeTime .dayOfWeek(DateTimeConstants.THURSDAY) .resolve(base); assertEquals(base .withDayOfWeek(DateTimeConstants.THURSDAY) .withTime(0, 0, 0, 0), absoluteTime); }
@Test public void testNextThursdayAt15() { LocalDateTime base = new LocalDateTime(2015, 12, 28, 9, 0, 0, 0); LocalDateTime absoluteTime = NextRelativeTime .dayOfWeek(DateTimeConstants.THURSDAY) .at(15,30) .resolve(base); assertEquals(base .withDayOfWeek(DateTimeConstants.THURSDAY) .withTime(15, 30, 0, 0), absoluteTime); }
public String toString() { if (HOUR_OF_DAY.equals(indexUnit)) { return "next time it's "+atHour+":"+atMinute; } else if (DAY_OF_WEEK.equals(indexUnit)) { return appendAt("next "+ dayOfWeekToString(index)); } else if (DAY_OF_MONTH.equals(indexUnit)) { return appendAt("next time it's the "+index+"th day of the month"); } return "next unspecified relative time"; }
public static NextRelativeTime dayOfWeek(Integer dayOfWeek) { return new NextRelativeTime(dayOfWeek, DAY_OF_WEEK); } public static NextRelativeTime dayOfMonth(Integer dayOfMonth) {
public static NextRelativeTime dayOfWeek(Integer dayOfWeek) { return new NextRelativeTime(dayOfWeek, DAY_OF_WEEK); } public static NextRelativeTime dayOfMonth(Integer dayOfMonth) {
public static NextRelativeTime hourOfDay(Integer hourOfDay) { return new NextRelativeTime(hourOfDay, HOUR_OF_DAY); } public static NextRelativeTime dayOfWeek(Integer dayOfWeek) {
public static NextRelativeTime dayOfMonth(Integer dayOfMonth) { return new NextRelativeTime(dayOfMonth, DAY_OF_MONTH); }
public static NextRelativeTime dayOfMonth(Integer dayOfMonth) { return new NextRelativeTime(dayOfMonth, DAY_OF_MONTH); }
public static RelativeTime readBpmnPolymorphic(BpmnReader r) { String type = r.readStringAttributeEffektif("type"); if (type==null) { String after = r.readStringAttributeEffektif("after"); if (after!=null) { return parseBackwardsCompatibleString(after); } return null; } RelativeTime relativeTime = null; if (AFTER.equals(type)) { relativeTime = new AfterRelativeTime(); } else if (BEFORE.equals(type)) { relativeTime = new BeforeRelativeTime(); } else if (NEXT.equals(type)) { relativeTime = new NextRelativeTime(); } else { throw new RuntimeException("TODO: Find out how to report parsing warning"); } relativeTime.readBpmn(r); return relativeTime; }
public static RelativeTime readBpmnPolymorphic(BpmnReader r) { String type = r.readStringAttributeEffektif("type"); if (type==null) { String after = r.readStringAttributeEffektif("after"); if (after!=null) { return parseBackwardsCompatibleString(after); } return null; } RelativeTime relativeTime = null; if (AFTER.equals(type)) { relativeTime = new AfterRelativeTime(); } else if (BEFORE.equals(type)) { relativeTime = new BeforeRelativeTime(); } else if (NEXT.equals(type)) { relativeTime = new NextRelativeTime(); } else { throw new RuntimeException("TODO: Find out how to report parsing warning"); } relativeTime.readBpmn(r); return relativeTime; }