Skip to content

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

Description

@pdowler

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions