Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cadc-soda-server: Cutout class allows invalid combination of values #68

Open
pdowler opened this issue Aug 6, 2021 · 0 comments
Open

Comments

@pdowler
Copy link
Member

pdowler commented Aug 6, 2021

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:

  1. 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.

  1. 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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant