xmlparser.utils.Builder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simplexml Show documentation
Show all versions of simplexml Show documentation
A clean and simple XML parser, serializer, and deserializer.
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