Java Map Put putMapBooleanList(Map params, String... keys)

Here you can find the source of putMapBooleanList(Map params, String... keys)

Description

put Map Boolean List

License

Open Source License

Declaration

public static Map<String, Object> putMapBooleanList(Map<String, Object> params, String... keys) 

Method Source Code


//package com.java2s;
/*//from  w w  w.  j a v  a  2 s.  c  o  m
 *
 *  *****************************************************************************
 *  * Copyright ( c ) 2016 Heren Tianjin Inc. All Rights Reserved.
 *  *
 *  * This software is the confidential and proprietary information of Heren Tianjin Inc
 *  * ("Confidential Information").  You shall not disclose such Confidential Information
 *  *  and shall use it only in accordance with the terms of the license agreement
 *  *  you entered into with Heren Tianjin or a Heren Tianjin authorized
 *  *  reseller (the "License Agreement").
 *  ****************************************************************************
 *
 */

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static Map<String, Object> putMapBooleanList(Map<String, Object> params, String... keys) {
        Map<String, Object> resultMap = new HashMap<>();
        Arrays.stream(keys).filter(key -> params.containsKey(key) && !params.get(key).equals(""))
                .forEach(key -> resultMap.put(change(key), params.get(key)));
        return resultMap;
    }

    private static String change(String param) {
        if (param.contains("_")) {
            String[] split = param.split("_");
            StringBuilder sb = new StringBuilder(split[0]);
            for (int i = 1; i < split.length; i++) {
                sb.append(split[i].substring(0, 1).toUpperCase()).append(split[i].substring(1));
            }
            return sb.toString();
        } else {
            return param;
        }
    }
}

Related

  1. putLong(Map properties, String key, long value)
  2. putLowerNotNull(Map m, String k, V v)
  3. putMap(Map map, Object... args)
  4. putMap(Map target, Map map)
  5. putMapBoolean(Map params, String key)
  6. putMapByPair(String pair, Map m)
  7. putMapEntry(Map map, String name, String value)
  8. putMapNotNullKey(Map map, K key, V value)
  9. putMapValue(String path, Object value, Map map)