code: private static int nextPosition(int a, int b) {
      return a < 0 ? b : b < 0 ? a : a < b ? a : b;
    }
docs: Helper that is similar to {@code Math.min(a,b)}, except that negative
  values are considered "invalid".
  
  @param a String position
  @param b String position
  @return {@code Math.min(a,b)} if {@code a >= 0} and {@code b >= 0},
  otherwise whichever is not negative.