src/main/java/com/squareup/connect/ApiClient.java
public List<Pair> parameterToPairs(String collectionFormat, String name, Object value){
    List<Pair> params = new ArrayList<Pair>();

    // preconditions
    if (name == null || name.isEmpty() || value == null) return params;

    Collection valueCollection;
    if (value instanceof Collection) {
      valueCollection = (Collection) value;
    } else {
      params.add(new Pair(name, parameterToString(value)));
      return params;
    }

    if (valueCollection.isEmpty()){
      return params;
    }

    // get the collection format (default: csv)
    String format = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat);

    // create the params based on the collection format
    if ("multi".equals(format)) {
      for (Object item : valueCollection) {
        params.add(new Pair(name, parameterToString(item)));
      }

      return params;
    }

    String delimiter = ",";

    if ("csv".equals(format)) {
      delimiter = ",";
    } else if ("ssv".equals(format)) {
      delimiter = " ";
    } else if ("tsv".equals(format)) {
      delimiter = "\t";
    } else if ("pipes".equals(format)) {
      delimiter = "|";
    }

    StringBuilder sb = new StringBuilder() ;
    for (Object item : valueCollection) {
      sb.append(delimiter);
      sb.append(parameterToString(item));
    }

    params.add(new Pair(name, sb.substring(1)));

    return params;
  }
/*
   * Format to {@code Pair} objects.
   * @param collectionFormat Collection format
   * @param name Name
   * @param value Value
   * @return List of pairs
   */
Format to  Pair objects.
@param collectionFormat Collection format
@param name Name
@param value Value
@return List of pairs
Format to Pair objects . @param collectionFormat Collection format @param name Name @param value Value @return List of pairs
public List<Pair> parameterToPairs(String collectionFormat, String name, Object value){
    List<Pair> params = new ArrayList<Pair>();
    if (name == null || name.isEmpty() || value == null) return params;
    Collection valueCollection;
    if (value instanceof Collection) {
      valueCollection = (Collection) value;
    } else {
      params.add(new Pair(name, parameterToString(value)));
      return params;
    }
    if (valueCollection.isEmpty()){
      return params;
    }
    String format = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat);
    if ("multi".equals(format)) {
      for (Object item : valueCollection) {
        params.add(new Pair(name, parameterToString(item)));
      }
      return params;
    }
    String delimiter = ",";
    if ("csv".equals(format)) {
      delimiter = ",";
    } else if ("ssv".equals(format)) {
      delimiter = " ";
    } else if ("tsv".equals(format)) {
      delimiter = "\t";
    } else if ("pipes".equals(format)) {
      delimiter = "|";
    }
    StringBuilder sb = new StringBuilder() ;
    for (Object item : valueCollection) {
      sb.append(delimiter);
      sb.append(parameterToString(item));
    }
    params.add(new Pair(name, sb.substring(1)));
    return params;
  }
public List < Pair > parameterToPairs ( String collectionFormat , String name , Object value ) { List < Pair > params = new ArrayList < Pair > ( ) ; if ( name == null || name . isEmpty ( ) || value == null ) return params ; Collection valueCollection ; if ( value instanceof Collection ) { valueCollection = ( Collection ) value ; } else { params . add ( new Pair ( name , parameterToString ( value ) ) ) ; return params ; } if ( valueCollection . isEmpty ( ) ) { return params ; } String format = ( collectionFormat == null || collectionFormat . isEmpty ( ) ? "csv" : collectionFormat ) ; if ( "multi" . equals ( format ) ) { for ( Object item : valueCollection ) { params . add ( new Pair ( name , parameterToString ( item ) ) ) ; } return params ; } String delimiter = "," ; if ( "csv" . equals ( format ) ) { delimiter = "," ; } else if ( "ssv" . equals ( format ) ) { delimiter = " " ; } else if ( "tsv" . equals ( format ) ) { delimiter = "\t" ; } else if ( "pipes" . equals ( format ) ) { delimiter = "|" ; } StringBuilder sb = new StringBuilder ( ) ; for ( Object item : valueCollection ) { sb . append ( delimiter ) ; sb . append ( parameterToString ( item ) ) ; } params . add ( new Pair ( name , sb . substring ( 1 ) ) ) ; return params ; }
Format to {@code Pair} objects.
Format to { @code Pair } objects .
// preconditions // get the collection format (default: csv) // create the params based on the collection format