@Test public void testGetS2SpectralBandIndex() throws Exception { int s2SpectralBandIndex = S2Utils.getS2SpectralBandIndex("B1"); assertEquals(0, s2SpectralBandIndex); s2SpectralBandIndex = S2Utils.getS2SpectralBandIndex("B9"); assertEquals(9, s2SpectralBandIndex); s2SpectralBandIndex = S2Utils.getS2SpectralBandIndex("B8A"); assertEquals(8, s2SpectralBandIndex); s2SpectralBandIndex = S2Utils.getS2SpectralBandIndex("B12"); assertEquals(12, s2SpectralBandIndex); }
static int getS2SpectralBandIndex(String bandName) { if (bandName.endsWith("B8A")) { return 8; } else { final int lastIndexOfB = bandName.lastIndexOf("B"); if (lastIndexOfB >= 0) { final int bandNumber = Integer.parseInt(bandName.substring(lastIndexOfB + 1, bandName.length())); return bandNumber < 9 ? bandNumber - 1 : bandNumber; } else { return -1; } } }
S2Utils { static int getS2SpectralBandIndex(String bandName) { if (bandName.endsWith("B8A")) { return 8; } else { final int lastIndexOfB = bandName.lastIndexOf("B"); if (lastIndexOfB >= 0) { final int bandNumber = Integer.parseInt(bandName.substring(lastIndexOfB + 1, bandName.length())); return bandNumber < 9 ? bandNumber - 1 : bandNumber; } else { return -1; } } } }
S2Utils { static int getS2SpectralBandIndex(String bandName) { if (bandName.endsWith("B8A")) { return 8; } else { final int lastIndexOfB = bandName.lastIndexOf("B"); if (lastIndexOfB >= 0) { final int bandNumber = Integer.parseInt(bandName.substring(lastIndexOfB + 1, bandName.length())); return bandNumber < 9 ? bandNumber - 1 : bandNumber; } else { return -1; } } }  }
S2Utils { static int getS2SpectralBandIndex(String bandName) { if (bandName.endsWith("B8A")) { return 8; } else { final int lastIndexOfB = bandName.lastIndexOf("B"); if (lastIndexOfB >= 0) { final int bandNumber = Integer.parseInt(bandName.substring(lastIndexOfB + 1, bandName.length())); return bandNumber < 9 ? bandNumber - 1 : bandNumber; } else { return -1; } } }   }
S2Utils { static int getS2SpectralBandIndex(String bandName) { if (bandName.endsWith("B8A")) { return 8; } else { final int lastIndexOfB = bandName.lastIndexOf("B"); if (lastIndexOfB >= 0) { final int bandNumber = Integer.parseInt(bandName.substring(lastIndexOfB + 1, bandName.length())); return bandNumber < 9 ? bandNumber - 1 : bandNumber; } else { return -1; } } }    }