From 190dc4d3fea527d027ba8e29af2dee465b6e102d Mon Sep 17 00:00:00 2001 From: lindenb Date: Tue, 29 Oct 2024 16:17:38 +0100 Subject: [PATCH] answer to https://github.com/samtools/htsjdk/pull/1726#issuecomment-2444507432 --- src/main/java/htsjdk/tribble/gff/Gff3BaseData.java | 2 +- src/main/java/htsjdk/tribble/gff/Gff3Feature.java | 4 ++-- src/test/java/htsjdk/tribble/gff/Gff3CodecTest.java | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/htsjdk/tribble/gff/Gff3BaseData.java b/src/main/java/htsjdk/tribble/gff/Gff3BaseData.java index 9692dd66c9..c1f746d261 100644 --- a/src/main/java/htsjdk/tribble/gff/Gff3BaseData.java +++ b/src/main/java/htsjdk/tribble/gff/Gff3BaseData.java @@ -187,7 +187,7 @@ public boolean hasAttribute(final String key) { * @return Optional<String> if this map contains zero or one attribute for the specified key * @throws IllegalArgumentException if there is more than one value */ - public Optional getAttr(final String key) { + public Optional getUniqueAttribute(final String key) { final List atts = getAttribute(key); switch(atts.size()) { case 0 : return Optional.empty(); diff --git a/src/main/java/htsjdk/tribble/gff/Gff3Feature.java b/src/main/java/htsjdk/tribble/gff/Gff3Feature.java index 005f0b73c5..37a879a5b9 100644 --- a/src/main/java/htsjdk/tribble/gff/Gff3Feature.java +++ b/src/main/java/htsjdk/tribble/gff/Gff3Feature.java @@ -77,8 +77,8 @@ default boolean hasAttribute(final String key) { * @return Optional<String> if this map contains zero or one attribute for the specified key * @throws IllegalArgumentException if there is more than one value. */ - default Optional getAttr(final String key) { - return getBaseData().getAttr(key); + default Optional getUniqueAttribute(final String key) { + return getBaseData().getUniqueAttribute(key); } default Map> getAttributes() { return getBaseData().getAttributes();} diff --git a/src/test/java/htsjdk/tribble/gff/Gff3CodecTest.java b/src/test/java/htsjdk/tribble/gff/Gff3CodecTest.java index 7a59cddd1f..38b9fb5d9c 100644 --- a/src/test/java/htsjdk/tribble/gff/Gff3CodecTest.java +++ b/src/test/java/htsjdk/tribble/gff/Gff3CodecTest.java @@ -80,7 +80,7 @@ public void codecFilterOutFieldsTest(final Path inputGff3, final int expectedTot for(final String key : skip_attributes) { Assert.assertTrue(feature.getAttribute(key).isEmpty()); Assert.assertFalse(feature.hasAttribute(key)); - Assert.assertFalse(feature.getAttr(key).isPresent()); + Assert.assertFalse(feature.getUniqueAttribute(key).isPresent()); } countTotalFeatures++; } @@ -203,8 +203,8 @@ public void urlDecodingTest() throws IOException { Assert.assertEquals(feature.getAttribute("Another key"), Arrays.asList("Another=value", "And a second, value")); Assert.assertTrue(feature.hasAttribute("Another key")); Assert.assertTrue(feature.hasAttribute(Gff3Constants.ID_ATTRIBUTE_KEY)); - Assert.assertTrue(feature.getAttr(Gff3Constants.ID_ATTRIBUTE_KEY).isPresent()); - Assert.assertFalse(feature.getAttr("missing").isPresent()); + Assert.assertTrue(feature.getUniqueAttribute(Gff3Constants.ID_ATTRIBUTE_KEY).isPresent()); + Assert.assertFalse(feature.getUniqueAttribute("missing").isPresent()); }