All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.ttddyy.dsproxy.proxy.ParameterKeyUtils Maven / Gradle / Ivy

There is a newer version: 1.10
Show newest version
package net.ttddyy.dsproxy.proxy;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author Tadaya Tsuyukubo
 * @since 1.4
 */
public class ParameterKeyUtils {
    public static  Map filterBy(Map map, ParameterKey.ParameterKeyType type) {
        Map result = new LinkedHashMap();
        for (Map.Entry entry : map.entrySet()) {
            ParameterKey key = entry.getKey();
            if (key.getType() == type) {
                result.put(key, entry.getValue());
            }
        }
        return result;
    }

    public static  Map toNameMap(Map map) {
        Map filtered = filterBy(map, ParameterKey.ParameterKeyType.BY_NAME);
        Map result = new LinkedHashMap();
        for (Map.Entry entry : filtered.entrySet()) {
            result.put(entry.getKey().getName(), entry.getValue());
        }
        return result;
    }

    public static  Map toIndexMap(Map map) {
        Map filtered = filterBy(map, ParameterKey.ParameterKeyType.BY_INDEX);
        Map result = new LinkedHashMap();
        for (Map.Entry entry : filtered.entrySet()) {
            result.put(entry.getKey().getIndex(), entry.getValue());
        }
        return result;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy