The Cutout class allows for a mix of sky (pos, band, time, pol, custom) and pixelCutouts when it doesn't make sense to mix pixel cutouts with the others. The public fields are consistent with other opencadc code where optional (null-able) fields are public and calling code knows to check and the class as-is supports instantiating a Cutout (holder) and assigning to fields as input params are processed, which is very convenient.
Two possible solutions:
- make the fields "public final" and provide constructors for the two sensible combinations:
public Cutout(Shape pos, Interval band, Interval time, List<PolarizationState> pol,
String customAxis, Interval custom)
public Cutout(List<ExtensionSlice> pixelCutouts
The first would have to allow some null arguments so checking is going to be ugly.
- preserve current style and utility but add a validate() method that the caller can use; this worked out well enough in caom2 Polygon where utility of building a polygon easily was more valuable than constructor validation.
I'd probably start with option 2 (public void validate() throws IllegalArgumentException) and use that in code that does new Cutout().
The Cutout class allows for a mix of sky (pos, band, time, pol, custom) and pixelCutouts when it doesn't make sense to mix pixel cutouts with the others. The public fields are consistent with other opencadc code where optional (null-able) fields are public and calling code knows to check and the class as-is supports instantiating a Cutout (holder) and assigning to fields as input params are processed, which is very convenient.
Two possible solutions:
The first would have to allow some null arguments so checking is going to be ugly.
I'd probably start with option 2 (
public void validate() throws IllegalArgumentException) and use that in code that doesnew Cutout().