From 0afb50988743f5b902ad985793d55104e419da85 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Tue, 8 Nov 2016 10:21:55 +0000 Subject: [PATCH] JAL-2292 renamed method and improved implementation as suggested by Kira --- src/jalview/util/Comparison.java | 18 ++++++------------ test/jalview/util/ComparisonTest.java | 14 +++++++------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/jalview/util/Comparison.java b/src/jalview/util/Comparison.java index 5269d4f..1326647 100644 --- a/src/jalview/util/Comparison.java +++ b/src/jalview/util/Comparison.java @@ -417,8 +417,8 @@ public class Comparison } /** - * Compares two chars either case sensitively or case insensitively depending - * on the caseSensitive flag + * Compares two residues either case sensitively or case insensitively + * depending on the caseSensitive flag * * @param c1 * first char @@ -428,18 +428,12 @@ public class Comparison * if true comparison will be case sensitive otherwise its not * @return */ - public static boolean compareChars(char c1, char c2, boolean caseSensitive) + public static boolean isSameResidue(char c1, char c2, + boolean caseSensitive) { - boolean sameCase = (Character.isUpperCase(c1) && Character - .isUpperCase(c2)) - || (Character.isLowerCase(c1) && Character.isLowerCase(c2)); - if (sameCase) + if (caseSensitive) { - return c1 == c2; - } - else if (caseSensitive) - { - return false; + return (c1 == c2); } else { diff --git a/test/jalview/util/ComparisonTest.java b/test/jalview/util/ComparisonTest.java index bce34d4..b71c270 100644 --- a/test/jalview/util/ComparisonTest.java +++ b/test/jalview/util/ComparisonTest.java @@ -190,14 +190,14 @@ public class ComparisonTest } @Test(groups = { "Functional" }) - public void compareCharsTest() + public void testIsSameResidue() { - assertTrue(Comparison.compareChars('a', 'a', false)); - assertTrue(Comparison.compareChars('a', 'a', true)); - assertTrue(Comparison.compareChars('A', 'a', false)); - assertTrue(Comparison.compareChars('a', 'A', false)); + assertTrue(Comparison.isSameResidue('a', 'a', false)); + assertTrue(Comparison.isSameResidue('a', 'a', true)); + assertTrue(Comparison.isSameResidue('A', 'a', false)); + assertTrue(Comparison.isSameResidue('a', 'A', false)); - assertFalse(Comparison.compareChars('a', 'A', true)); - assertFalse(Comparison.compareChars('A', 'a', true)); + assertFalse(Comparison.isSameResidue('a', 'A', true)); + assertFalse(Comparison.isSameResidue('A', 'a', true)); } } -- 1.7.10.2