Source:
private final ConfigCreatorResult createCommonConfig(final int numberExposures) { final CalculationMethod calcMethod = obsDetailParams.calculationMethod(); final ConfigCreatorResult result = new ConfigCreatorResult(new DefaultConfig[numberExposures]); if (numberExposures < 1) { result.addWarning("Warning: The number of exposures must be > 0."); } final int numberCoadds = calcMethod.coaddsOrElse(1); final double offset = calcMethod.offset(); final List<Double> spectroscopyOffsets = new ArrayList<>(Arrays.asList(0.0, offset, offset, 0.0)); final List<Double> imagingOffsets = new ArrayList<>(Arrays.asList(0.0, offset, 0.0, offset)); final List<Double> offsetList = new ArrayList<>(); for (int i = 0; i < (1 + numberExposures / 4); i++) { if (calcMethod instanceof Imaging || obsDetailParams.analysisMethod() instanceof IfuMethod) { offsetList.addAll(imagingOffsets); result.setOffsetMessage("ABAB dithering pattern"); } else if (calcMethod instanceof Spectroscopy) { offsetList.addAll(spectroscopyOffsets); result.setOffsetMessage("ABBA dithering pattern"); } } for (int i = 0; i < numberExposures; i++) { final Config step = new DefaultConfig(); step.putItem(ExposureTimeKey, obsDetailParams.exposureTime()); step.putItem(ObserveTypeKey, InstConstants.SCIENCE_OBSERVE_TYPE); step.putItem(ObserveClassKey, ObsClass.SCIENCE); step.putItem(CoaddsKey, numberCoadds); step.putItem(TelescopePKey, 0.0); step.putItem(TelescopeQKey, offsetList.get(i)); if (itcParams.telescope().getWFS().equals(GuideProbe.Type.PWFS)) { step.putItem(GuideWithPWFS2Key, StandardGuideOptions.Value.guide); } result.getConfig()[i] = step; } return result; }

Target:
private ConfigCreatorResult createCommonConfig(final int numberExposures) { if (numberExposures <= 0) { throw new IllegalArgumentException("The number of exposures must be at least 1."); } final CalculationMethod calcMethod = obsDetailParams.calculationMethod(); final ConfigCreatorResult result = new ConfigCreatorResult(new DefaultConfig[numberExposures]); final int numberCoadds = calcMethod.coaddsOrElse(1); final double offset = calcMethod.offset(); final List<Double> spectroscopyOffsets = new ArrayList<>(Arrays.asList(0.0, offset, offset, 0.0)); final List<Double> imagingOffsets = new ArrayList<>(Arrays.asList(0.0, offset, 0.0, offset)); final List<Double> offsetList = new ArrayList<>(); for (int i = 0; i < (1 + numberExposures / 4); i++) { if (calcMethod instanceof Imaging || obsDetailParams.analysisMethod() instanceof IfuMethod) { offsetList.addAll(imagingOffsets); result.setOffsetMessage("ABAB dithering pattern"); } else if (calcMethod instanceof Spectroscopy) { offsetList.addAll(spectroscopyOffsets); result.setOffsetMessage("ABBA dithering pattern"); } } for (int i = 0; i < numberExposures; i++) { final Config step = new DefaultConfig(); step.putItem(ExposureTimeKey, obsDetailParams.exposureTime()); step.putItem(ObserveTypeKey, InstConstants.SCIENCE_OBSERVE_TYPE); step.putItem(ObserveClassKey, ObsClass.SCIENCE); step.putItem(CoaddsKey, numberCoadds); step.putItem(TelescopePKey, 0.0); step.putItem(TelescopeQKey, offsetList.get(i)); if (itcParams.telescope().getWFS().equals(GuideProbe.Type.PWFS)) { step.putItem(GuideWithPWFS2Key, StandardGuideOptions.Value.guide); } result.getConfig()[i] = step; } return result; }