Description: some pieces of syntax are for OpenJDK-21, which is not yet the
 default one in Debian. Let's remove this patch when it is.
Author: Pierre Gruet <pgt@debian.org>
Forwarded: not-needed
Last-Update: 2024-04-21

--- a/src/java/org/broadinstitute/dropseqrna/annotation/functionaldata/DataProcessorUtils.java
+++ b/src/java/org/broadinstitute/dropseqrna/annotation/functionaldata/DataProcessorUtils.java
@@ -140,7 +140,7 @@
                 finalLF = AnnotationUtils.getInstance().getLocusFunction(lf, false);
             }
             // any instance of list l is fine.
-            FunctionalData result = new FunctionalData(l.getFirst().getGene(), l.getFirst().getGeneStrand(), finalLF, l.getFirst().getReadStrand());
+            FunctionalData result = new FunctionalData(l.get(0).getGene(), l.get(0).getGeneStrand(), finalLF, l.get(0).getReadStrand());
             resultList.add(result);
         }
         return (resultList);
--- a/src/java/org/broadinstitute/dropseqrna/annotation/functionaldata/DropSeqPriorityScore.java
+++ b/src/java/org/broadinstitute/dropseqrna/annotation/functionaldata/DropSeqPriorityScore.java
@@ -4,14 +4,20 @@
 
 public class DropSeqPriorityScore implements PriorityScoreI {
     public int getScore(FunctionalData fd) {
-        int result = switch (fd.getLocusFunction()) {
-            case null -> Integer.MAX_VALUE;
-            case LocusFunction.CODING -> 1;
-            case LocusFunction.UTR -> 1;
-            case LocusFunction.INTRONIC -> 2;
-            case LocusFunction.INTERGENIC -> 3;
-            default -> Integer.MAX_VALUE;
-        };
+        int result;
+        if (fd.getLocusFunction() == null) {
+            result = Integer.MAX_VALUE;
+        } else if (fd.getLocusFunction() == LocusFunction.CODING) {
+            result = 1;
+        } else if (fd.getLocusFunction() == LocusFunction.UTR) {
+            result = 1;
+        } else if (fd.getLocusFunction() == LocusFunction.INTRONIC) {
+            result = 2;
+        } else if (fd.getLocusFunction() == LocusFunction.INTERGENIC) {
+            result = 3;
+        } else {
+            result = Integer.MAX_VALUE;
+        }
 
         return result;
     }
--- a/src/java/org/broadinstitute/dropseqrna/annotation/functionaldata/disambiguate/ClassifyDropSeqFunctionalData.java
+++ b/src/java/org/broadinstitute/dropseqrna/annotation/functionaldata/disambiguate/ClassifyDropSeqFunctionalData.java
@@ -130,7 +130,7 @@
         // simplify multiple annotations on the same gene.
 
         if (filtered.isEmpty() && antisense.size()==1) {
-            return antisense.getFirst();
+            return antisense.get(0);
         }
         return null;
     }
@@ -145,7 +145,7 @@
         List<FunctionalData> filtered = filterFunctionalData (fdList);
         List<FunctionalData> sense = filtered.stream().filter(FunctionalData::isSense).toList();
         if (sense.size()==1) {
-            return sense.getFirst();
+            return sense.get(0);
         }
         return null;
     }
--- a/src/java/org/broadinstitute/dropseqrna/annotation/functionaldata/disambiguate/OptimusDropSeqLocusFunctionComparison.java
+++ b/src/java/org/broadinstitute/dropseqrna/annotation/functionaldata/disambiguate/OptimusDropSeqLocusFunctionComparison.java
@@ -127,8 +127,8 @@
             if (recs.size()<2)
                 continue;
 
-            String cellBarcode = recs.getFirst().getStringAttribute(this.CELL_BARCODE_TAG);
-            String umiBarcode = recs.getFirst().getStringAttribute(this.MOLECULAR_BARCODE_TAG);
+            String cellBarcode = recs.get(0).getStringAttribute(this.CELL_BARCODE_TAG);
+            String umiBarcode = recs.get(0).getStringAttribute(this.MOLECULAR_BARCODE_TAG);
 
             Map<String, List<FunctionalData>> dropSeqFD = getFunctionalAnnotations(recs);
 
--- a/src/java/org/broadinstitute/dropseqrna/beadsynthesis/CorrectAndSplitScrnaReadPairs.java
+++ b/src/java/org/broadinstitute/dropseqrna/beadsynthesis/CorrectAndSplitScrnaReadPairs.java
@@ -171,7 +171,7 @@
                 }
                 ++metrics.NUM_READS_CORRECTED_SINGLE_ED1;
                 numCandidatesHist.increment(1);
-                return ed1Matches.getFirst();
+                return ed1Matches.get(0);
             } else {
                 String bestBarcode = null;
                 double bestBarcodeLikelihood = 0;
--- a/src/java/org/broadinstitute/dropseqrna/beadsynthesis/CountBarcodeSequences.java
+++ b/src/java/org/broadinstitute/dropseqrna/beadsynthesis/CountBarcodeSequences.java
@@ -115,7 +115,7 @@
   final SamReaderFactory readerFactory = SamReaderFactory.makeDefault();
   final List<SamReader> readers = INPUT.stream().map(readerFactory::open).toList();
   // Header is not important, but we need one to iterate
-  final SAMFileHeader header = readers.getFirst().getFileHeader();
+  final SAMFileHeader header = readers.get(0).getFileHeader();
   final CloseableIterator<SAMRecord> it = new UnsortedMergingSamRecordIterator(header, readers);
   final Histogram<String> histogram = new Histogram<>("SEQUENCE", "COUNT");
 
--- a/src/java/org/broadinstitute/dropseqrna/utils/readiterators/GeneFunctionProcessor.java
+++ b/src/java/org/broadinstitute/dropseqrna/utils/readiterators/GeneFunctionProcessor.java
@@ -63,7 +63,7 @@
 		// If there's only one functional data result, re-tag the read, and
 		// queue it, then short circuit out.
 		if (fdList.size() == 1) {
-			FunctionalData fd = fdList.getFirst();
+			FunctionalData fd = fdList.get(0);
 			SAMRecord rr = assignTagsToRead(r, fd);
 			result.add(rr);
 			return result;
@@ -114,11 +114,11 @@
 //		}
 
 		// test if all functional annotations are the same as the first entry.
-		FunctionalData first = fdList.getFirst();
+		FunctionalData first = fdList.get(0);
 		boolean allSame = fdList.stream().allMatch(first::sameGeneAndType);
 		// if so, assign and finish.
 		if (allSame)
-            return (assignTagsToRead(recs.getFirst(), first));
+            return (assignTagsToRead(recs.get(0), first));
 
 		return null;
 	}
--- a/src/java/org/broadinstitute/dropseqrna/utils/readiterators/SamFileMergeUtil.java
+++ b/src/java/org/broadinstitute/dropseqrna/utils/readiterators/SamFileMergeUtil.java
@@ -68,14 +68,14 @@
                     inputSortOrder = header.getSortOrder();
                 } else if (header.getSortOrder() != inputSortOrder) {
                     throw new PicardException(String.format("Sort order(%s) of %s does not agree with sort order(%s) of %s",
-                            header.getSortOrder(), inFile.getAbsolutePath(), inputSortOrder, inputs.getFirst().getAbsolutePath()));
+                            header.getSortOrder(), inFile.getAbsolutePath(), inputSortOrder, inputs.get(0).getAbsolutePath()));
                 }
             }
             headers.add(header);
         }
 
         if (inputs.size() == 1) {
-            return new SamHeaderAndIterator(headers.getFirst(), readers.getFirst().iterator());
+            return new SamHeaderAndIterator(headers.get(0), readers.get(0).iterator());
         } else {
             final SAMFileHeader.SortOrder outputSortOrder;
             if (maintainSort) {
@@ -132,4 +132,4 @@
         }
         return new SamHeaderAndIterator(headerMerger.getMergedHeader(), iterator);
     }
-}
\ No newline at end of file
+}
--- a/src/java/org/broadinstitute/dropseqrna/annotation/functionaldata/StarSoloPriorityScore.java
+++ b/src/java/org/broadinstitute/dropseqrna/annotation/functionaldata/StarSoloPriorityScore.java
@@ -8,13 +8,18 @@
 public class StarSoloPriorityScore implements PriorityScoreI {
 
     public int getScore(FunctionalData fd) {
-        int result = switch (fd.getLocusFunction()) {
-            case LocusFunction.CODING -> 1;
-            case LocusFunction.UTR -> 1;
-            case LocusFunction.INTRONIC -> 2;
-            case LocusFunction.INTERGENIC -> 3;
-            default -> Integer.MAX_VALUE;
-        };
+        int result;
+        if (fd.getLocusFunction() == LocusFunction.CODING) {
+            result = 1;
+        } else if (fd.getLocusFunction() == LocusFunction.UTR) {
+            result = 1;
+        } else if (fd.getLocusFunction() == LocusFunction.INTRONIC) {
+            result = 2;
+        } else if (fd.getLocusFunction() == LocusFunction.INTERGENIC) {
+            result = 3;
+        } else {
+            result = Integer.MAX_VALUE;
+        }
 
         return result;
     }
--- a/src/tests/java/org/broadinstitute/dropseqrna/annotation/functionaldata/DropSeqFunctionalDataProcessorTest.java
+++ b/src/tests/java/org/broadinstitute/dropseqrna/annotation/functionaldata/DropSeqFunctionalDataProcessorTest.java
@@ -84,7 +84,7 @@
 		// SENSE STRAND TEST positive strand
 		List<FunctionalData> fdList = fdp.getFilteredFunctionalData(genes, strands, locusFunctions, false);
 		Assert.assertEquals(fdList.size(), 1);
-		FunctionalData fd = fdList.getFirst();
+		FunctionalData fd = fdList.get(0);
 		Assert.assertEquals(fd.getGene(), genes[0]);
 		Assert.assertEquals(fd.getGeneStrand(), strands[0]);
 		Assert.assertEquals(fd.getLocusFunction(), locusFunctions[0]);
@@ -136,7 +136,7 @@
 
 		List<FunctionalData> fdList = fdp.getFilteredFunctionalData(genes, strands, locusFunctions, false);
 		Assert.assertEquals(fdList.size(), 1);
-		FunctionalData fd = fdList.getFirst();
+		FunctionalData fd = fdList.get(0);
 		Assert.assertEquals(fd.getGene(), genes[0]);
 		Assert.assertEquals(fd.getGeneStrand(), strands[0]);
 		Assert.assertEquals(fd.getLocusFunction(), locusFunctions[0]);
--- a/src/tests/java/org/broadinstitute/dropseqrna/annotation/functionaldata/StarSoloFunctionalDataProcessorTest.java
+++ b/src/tests/java/org/broadinstitute/dropseqrna/annotation/functionaldata/StarSoloFunctionalDataProcessorTest.java
@@ -82,7 +82,7 @@
 		// SENSE STRAND TEST positive strand
 		List<FunctionalData> fdList = fdp.getFilteredFunctionalData(genes, strands, locusFunctions, false);
 		Assert.assertEquals(fdList.size(), 2);
-		FunctionalData fd = fdList.getFirst();
+		FunctionalData fd = fdList.get(0);
 		Assert.assertEquals(fd.getGene(), genes[0]);
 		Assert.assertEquals(fd.getGeneStrand(), strands[0]);
 		Assert.assertEquals(fd.getLocusFunction(), locusFunctions[0]);
@@ -134,7 +134,7 @@
 
 		List<FunctionalData> fdList = fdp.getFilteredFunctionalData(genes, strands, locusFunctions, false);
 		Assert.assertEquals(fdList.size(), 1);
-		FunctionalData fd = fdList.getFirst();
+		FunctionalData fd = fdList.get(0);
 		Assert.assertEquals(fd.getGene(), genes[0]);
 		Assert.assertEquals(fd.getGeneStrand(), strands[0]);
 		Assert.assertEquals(fd.getLocusFunction(), locusFunctions[0]);
@@ -316,7 +316,7 @@
 		// once you filter to the preferred annotations, only the intronic gene is retained
 		fdList = fdp.filterToPreferredAnnotations(fdList);
 		Assert.assertEquals(fdList.size(), 1);
-		Assert.assertEquals(fdList.getFirst().getGene(), "B");
+		Assert.assertEquals(fdList.get(0).getGene(), "B");
 
 	}
 
