public static List<Pair> splitPairs(String string, char pairsSeparator, char componentsSeparator)
  {
    if(string == null) {
      return null;
    }
    string = string.trim();

    final int length = string.length();
    final List<Pair> list = new ArrayList<Pair>();
    int beginIndex = 0;
    int endIndex = 0;

    while(endIndex < length) {
      if(string.charAt(endIndex) == pairsSeparator) {
        if(endIndex > beginIndex) {
          list.add(pair(string.substring(beginIndex, endIndex), componentsSeparator));
        }
        beginIndex = ++endIndex;
      }
      ++endIndex;
    }
    if(beginIndex < length) {
      list.add(pair(string.substring(beginIndex), componentsSeparator));
    }
    return list;
  }
public static List < Pair > splitPairs ( String string , char pairsSeparator , char componentsSeparator ) { if ( string == null ) { return null ; } string = string . trim ( ) ; final int length = string . length ( ) ; final List < Pair > list = new ArrayList < Pair > ( ) ; int beginIndex = 0 ; int endIndex = 0 ; while ( endIndex < length ) { if ( string . charAt ( endIndex ) == pairsSeparator ) { if ( endIndex > beginIndex ) { list . add ( pair ( string . substring ( beginIndex , endIndex ) , componentsSeparator ) ) ; } beginIndex = ++ endIndex ; } ++ endIndex ; } if ( beginIndex < length ) { list . add ( pair ( string . substring ( beginIndex ) , componentsSeparator ) ) ; } return list ; }
Split string using given pairs separator and every pair using pair component separator. Return the list of pair
instances, possible empty if string value is empty. Returns null if string value is null.
<p>
Returned pair components are trimmed for spaces. This means that spaces around separators are eliminated; this is
true for both pairs and pair components separators. For example, " john : doe ; jane : doe ; " will return
Pair("john", "doe"), Pair("jane", "doe").
<p>
Trailing pairs separator is optional.

@param string string value,
@param pairsSeparator pairs separator,
@param componentsSeparator pair components separator.
@return list of pairs, possible empty.
@throws BugError if a pair is not valid, that is, pair components separator is missing.