MphChlOp extends Operator { static Sensor getSensorFromBrrSourceProduct(String[] sourceBands) { Sensor[] sensors = {Sensor.OLCI, Sensor.MERIS_3RD, Sensor.MERIS_4TH}; for (Sensor sensor : sensors) { boolean containsBand = false; for (String requiredBandName : sensor.getRequiredBrrBandNames()) { containsBand = false; for (String sourceBandName : sourceBands) { if (sourceBandName.equals(requiredBandName)) { containsBand = true; } } if (!containsBand) { break; } } if (containsBand) { return sensor; } } return null; }  @Override void initialize();  }
@Test public void testGetSensorFromBrrSourceProduct() { String[] sourceBands = MphChlConstants.MERIS_REQUIRED_BRR_BAND_NAMES; Sensor sensor = MphChlOp.getSensorFromBrrSourceProduct(sourceBands); assertNotNull(sensor); assertEquals(Sensor.MERIS_3RD, sensor); sourceBands = MphChlConstants.OLCI_REQUIRED_BRR_BAND_NAMES; sensor = MphChlOp.getSensorFromBrrSourceProduct(sourceBands); assertNotNull(sensor); assertEquals(Sensor.OLCI, sensor); sourceBands = new String[]{"bla","blubb"}; sensor = MphChlOp.getSensorFromBrrSourceProduct(sourceBands); assertNull(sensor); }