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

group.rxcloud.capa.addons.serialzer.value.parser.MapParser Maven / Gradle / Ivy

package group.rxcloud.capa.addons.serialzer.value.parser;


import group.rxcloud.capa.addons.serialzer.collect.KeyValuePair;
import group.rxcloud.capa.addons.serialzer.value.StringValues;

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

public class MapParser implements ValueParser> {

    public static final MapParser DEFAULT = new MapParser();

    @Override
    public Map parse(String value) {
        if (StringValues.isNullOrWhitespace(value))
            return null;

        Map map = new HashMap();
        String[] pairValues = value.trim().split(",");
        for (String pairValue : pairValues) {
            KeyValuePair pair = StringValues.toKeyValuePair(pairValue);
            if (pair == null)
                continue;

            map.put(pair.getKey(), pair.getValue());
        }

        return map.size() == 0 ? null : map;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy