/** * Split string value using given separator and return initialized pair instance. Pair values are trimmed for spaces * so that this method eliminates spaces around separator and around string value. For example, " john : doe " will * return Pair("john", "doe"). * * @param string string value, * @param separator pair components separator. * @return newly create pair instance. * @throws BugError if separator not found. */ private static Pair pair(String string, char separator) { int separatorIndex = string.indexOf(separator); if(separatorIndex == -1) { throw new BugError("Missing pair separator. Cannot initialize pair instance."); } final String first = string.substring(0, separatorIndex).trim(); final String second = string.substring(separatorIndex + 1).trim(); return new Pair(first, second); }
Pair pair = new Pair(firstValue, expression.substring(colonIndex, semicolonIndex)); if(pairs.contains(pair)) { throw new SyntaxException("Duplicated pairs in expression |%s|.", expression);