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

xmlparser.utils.Builder Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version
package xmlparser.utils;

import java.text.NumberFormat;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;

public enum Builder {;

    private static final NumberFormat NUMBER_FORMAT = NumberFormat.getInstance();

    public static Number toNumber(final String s) {
        try {
            return NUMBER_FORMAT.parse(s);
        }
        catch (ParseException e) {
            return null;
        }
    }

    public static  MapBuilder newHashMap() {
        return new MapBuilder(new HashMap<>());
    }
    public static class MapBuilder {
        private final Map map;
        public MapBuilder(final Map map) {
            this.map = map;
        }
        public MapBuilder put(K k, V v) {
            this.map.put(k, v);
            return this;
        }
        public Map build() {
            return this.map;
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy