Java List Create createMultiSelectionValue(List values)

Here you can find the source of createMultiSelectionValue(List values)

Description

create Multi Selection Value

License

Open Source License

Parameter

Parameter Description
values list of option values

Return

multiselection value combined from values list example: List = [A,X,Z] retuns "A" "X" "Z"

Declaration

public static String createMultiSelectionValue(List<String> values) 

Method Source Code

//package com.java2s;
/*/*from   w  ww  .j  a  v  a2 s .  c o m*/
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 * 
 * Initial Contributors:
 * Nokia Corporation - Initial contribution
 * 
 * Contributors:
 * 
 * Description: This file is part of com.nokia.tools.variant.viewer component.
 */

import java.util.Collections;
import java.util.List;

public class Main {
    /**
     * 
     * @param values list of option values
     * @return multiselection value combined from values list
     * 
     * example:
     * List<String> = [A,X,Z]
     * 
     * retuns "A" "X" "Z"
     * 
     */
    public static String createMultiSelectionValue(List<String> values) {
        Collections.sort(values);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < values.size(); i++) {
            if (i > 0) {
                sb.append(' ');
            }

            sb.append("\"" + values.get(i) + "\"");
        }

        return sb.toString();
    }
}

Related

  1. createMapFromList(List list)
  2. createMapOfObjects(List keys, List values)
  3. createMatrix(List source, List target)
  4. createMergedRegex(List regexes)
  5. createMultiParamMessage(String aPrefix, String aSuffix, List aParams)
  6. createMutableList(Collection collection)
  7. createNewList(Class type)
  8. createNormalDistributionByBootstrapping( List values1, List values2, final List sums1, final List sums2)
  9. createNormativeTroopAllocation( List probs)