#157 RegularTimePeriods .next() return types

closed-rejected
David Gilbert
None
5
2007-03-30
2007-03-28
Nick Guenther
No

All the RegularTimePeriod implementations (Year, Month, etc.) right now have a .next that looks something like:

public RegularTimePeriod next() {
if (this.year < SerialDate.MAXIMUM_YEAR_SUPPORTED) {
return new Year(this.year + 1);
}
else {
return null;
}
}

I propose that the declared return types should just be changed to match what they actually return. That is, in this example we'd change:
public RegularTimePeriod next() --> public Year next()

This lets you write loops over these without casting or restricting yourself to just referencing RegularTimePeriod-typed variables.

Discussion

  • David Gilbert
    David Gilbert
    2007-03-30

    Logged In: YES
    user_id=112975
    Originator: NO

    I think the change is possible in Java 1.5 and 1.6, but it doesn't compile in 1.4 and 1.3 which we are still supporting, so it will have to remain the way it is unfortunately.

     
  • David Gilbert
    David Gilbert
    2007-03-30

    • assigned_to: nobody --> mungady
    • status: open --> closed-rejected