AllelePosition { public static AllelePosition trim(int pos, String ref, String alt) { Objects.requireNonNull(ref, "REF string cannot be null"); Objects.requireNonNull(alt, "ALT string cannot be null"); if (cantTrim(ref, alt)) { return new AllelePosition(pos, ref, alt); } if (needsRightTrim(ref, alt)) { int rightIdx = ref.length(); int diff = ref.length() - alt.length(); while (rightIdx > 1 && rightIdx - diff > 0 && ref.charAt(rightIdx - 1) == alt.charAt(rightIdx - 1 - diff)) { rightIdx--; } ref = ref.substring(0, rightIdx); alt = alt.substring(0, rightIdx - diff); } if (needsLeftTrim(ref, alt)) { int leftIdx = 0; while (leftIdx < ref.length() && leftIdx < alt.length() && ref.charAt(leftIdx) == alt.charAt(leftIdx)) { leftIdx++; } if (leftIdx > 0 && leftIdx == ref.length() || leftIdx == alt.length()) { leftIdx -= 1; } pos += leftIdx; ref = ref.substring(leftIdx); alt = alt.substring(leftIdx); } return new AllelePosition(pos, ref, alt); } private  AllelePosition(int pos, String ref, String alt); static AllelePosition of(int pos, String ref, String alt); static AllelePosition trim(int pos, String ref, String alt); static boolean isSnv(String ref, String alt); static boolean isDeletion(String ref, String alt); static boolean isInsertion(String ref, String alt); static boolean isSymbolic(String ref, String alt); int getPos(); String getRef(); String getAlt(); boolean isSymbolic(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testNullRef() { assertThrows(NullPointerException.class, () -> trim(1, null, "A")); }
@Test public void testNullAlt() { assertThrows(NullPointerException.class, () -> trim(1, "T", null)); }