core模块
Console
package cn.hutool.core.lang;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.CharUtil;
import cn.hutool.core.util.StrUtil;
import java.util.Scanner;
import static java.lang.System.err;
import static java.lang.System.out;
public class Console {
private static final String TEMPLATE_VAR = "{}";
public static void log() {
out.println();
}
public static void log(Object obj) {
if (obj instanceof Throwable) {
final Throwable e = (Throwable) obj;
log(e, e.getMessage());
} else {
log(TEMPLATE_VAR, obj);
}
}
public static void log(Object obj1, Object... otherObjs) {
if (ArrayUtil.isEmpty(otherObjs)) {
log(obj1);
} else {
log(buildTemplateSplitBySpace(otherObjs.length + 1), ArrayUtil.insert(otherObjs, 0, obj1));
}
}
public static void log(String template, Object... values) {
if (ArrayUtil.isEmpty(values) || StrUtil.contains(template, TEMPLATE_VAR)) {
logInternal(template, values);
} else {
logInternal(buildTemplateSplitBySpace(values.length + 1), ArrayUtil.insert(values, 0, template));
}
}
public static void log(Throwable t, String template, Object... values) {
out.println(StrUtil.format(template, values));
if (null != t) {
t.printStackTrace();
out.flush();
}
}
private static void logInternal(String template, Object... values) {
log(null, template, values);
}
public static void table(ConsoleTable consoleTable) {
print(consoleTable.toString());
}
public static void print(Object obj) {
print(TEMPLATE_VAR, obj);
}
public static void print(Object obj1, Object... otherObjs) {
if (ArrayUtil.isEmpty(otherObjs)) {
print(obj1);
} else {
print(buildTemplateSplitBySpace(otherObjs.length + 1), ArrayUtil.insert(otherObjs, 0, obj1));
}
}
public static void print(String template, Object... values) {
if (ArrayUtil.isEmpty(values) || StrUtil.contains(template, TEMPLATE_VAR)) {
printInternal(template, values);
} else {
printInternal(buildTemplateSplitBySpace(values.length + 1), ArrayUtil.insert(values, 0, template));
}
}
public static void printProgress(char showChar, int len) {
print("{}{}", CharUtil.CR, StrUtil.repeat(showChar, len));
}
public static void printProgress(char showChar, int totalLen, double rate) {
Assert.isTrue(rate >= 0 && rate <= 1, "Rate must between 0 and 1 (both include)");
printProgress(showChar, (int) (totalLen * rate));
}
private static void printInternal(String template, Object... values) {
out.print(StrUtil.format(template, values));
}
public static void error() {
err.println();
}
public static void error(Object obj) {
if (obj instanceof Throwable) {
Throwable e = (Throwable) obj;
error(e, e.getMessage());
} else {
error(TEMPLATE_VAR, obj);
}
}
public static void error(Object obj1, Object... otherObjs) {
if (ArrayUtil.isEmpty(otherObjs)) {
error(obj1);
} else {
error(buildTemplateSplitBySpace(otherObjs.length + 1), ArrayUtil.insert(otherObjs, 0, obj1));
}
}
public static void error(String template, Object... values) {
if (ArrayUtil.isEmpty(values) || StrUtil.contains(template, TEMPLATE_VAR)) {
errorInternal(template, values);
} else {
errorInternal(buildTemplateSplitBySpace(values.length + 1), ArrayUtil.insert(values, 0, template));
}
}
public static void error(Throwable t, String template, Object... values) {
err.println(StrUtil.format(template, values));
if (null != t) {
t.printStackTrace(err);
err.flush();
}
}
private static void errorInternal(String template, Object... values) {
error(null, template, values);
}
public static Scanner scanner() {
return new Scanner(System.in);
}
public static String input() {
return scanner().nextLine();
}
public static String where() {
final StackTraceElement stackTraceElement = new Throwable().getStackTrace()[1];
final String className = stackTraceElement.getClassName();
final String methodName = stackTraceElement.getMethodName();
final String fileName = stackTraceElement.getFileName();
final Integer lineNumber = stackTraceElement.getLineNumber();
return String.format("%s.%s(%s:%s)", className, methodName, fileName, lineNumber);
}
public static Integer lineNumber() {
return new Throwable().getStackTrace()[1].getLineNumber();
}
private static String buildTemplateSplitBySpace(int count) {
return StrUtil.repeatAndJoin(TEMPLATE_VAR, count, StrUtil.SPACE);
}
}
Converter万能转换器
Converter接口
package cn.hutool.core.convert;
public interface Converter<T> {
T convert(Object value, T defaultValue) throws IllegalArgumentException;
}
Converter
package cn.hutool.core.convert;
import cn.hutool.core.convert.impl.CollectionConverter;
import cn.hutool.core.convert.impl.EnumConverter;
import cn.hutool.core.convert.impl.MapConverter;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.text.UnicodeUtil;
import cn.hutool.core.util.ByteUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.ClassUtil;
import cn.hutool.core.util.HexUtil;
import cn.hutool.core.util.StrUtil;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.Charset;
import java.time.Instant;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
public class Convert {
public static String toStr(Object value, String defaultValue) {
return convertQuietly(String.class, value, defaultValue);
}
public static String toStr(Object value) {
return toStr(value, null);
}
public static String[] toStrArray(Object value) {
return convert(String[].class, value);
}
public static Character toChar(Object value, Character defaultValue) {
return convertQuietly(Character.class, value, defaultValue);
}
public static Character toChar(Object value) {
return toChar(value, null);
}
public static Character[] toCharArray(Object value) {
return convert(Character[].class, value);
}
public static Byte toByte(Object value, Byte defaultValue) {
return convertQuietly(Byte.class, value, defaultValue);
}
public static Byte toByte(Object value) {
return toByte(value, null);
}
public static Byte[] toByteArray(Object value) {
return convert(Byte[].class, value);
}
public static byte[] toPrimitiveByteArray(Object value) {
return convert(byte[].class, value);
}
public static Short toShort(Object value, Short defaultValue) {
return convertQuietly(Short.class, value, defaultValue);
}
public static Short toShort(Object value) {
return toShort(value, null);
}
public static Short[] toShortArray(Object value) {
return convert(Short[].class, value);
}
public static Number toNumber(Object value, Number defaultValue) {
return convertQuietly(Number.class, value, defaultValue);
}
public static Number toNumber(Object value) {
return toNumber(value, null);
}
public static Number[] toNumberArray(Object value) {
return convert(Number[].class, value);
}
public static Integer toInt(Object value, Integer defaultValue) {
return convertQuietly(Integer.class, value, defaultValue);
}
public static Integer toInt(Object value) {
return toInt(value, null);
}
public static Integer[] toIntArray(Object value) {
return convert(Integer[].class, value);
}
public static Long toLong(Object value, Long defaultValue) {
return convertQuietly(Long.class, value, defaultValue);
}
public static Long toLong(Object value) {
return toLong(value, null);
}
public static Long[] toLongArray(Object value) {
return convert(Long[].class, value);
}
public static Double toDouble(Object value, Double defaultValue) {
return convertQuietly(Double.class, value, defaultValue);
}
public static Double toDouble(Object value) {
return toDouble(value, null);
}
public static Double[] toDoubleArray(Object value) {
return convert(Double[].class, value);
}
public static Float toFloat(Object value, Float defaultValue) {
return convertQuietly(Float.class, value, defaultValue);
}
public static Float toFloat(Object value) {
return toFloat(value, null);
}
public static Float[] toFloatArray(Object value) {
return convert(Float[].class, value);
}
public static Boolean toBool(Object value, Boolean defaultValue) {
return convertQuietly(Boolean.class, value, defaultValue);
}
public static Boolean toBool(Object value) {
return toBool(value, null);
}
public static Boolean[] toBooleanArray(Object value) {
return convert(Boolean[].class, value);
}
public static BigInteger toBigInteger(Object value, BigInteger defaultValue) {
return convertQuietly(BigInteger.class, value, defaultValue);
}
public static BigInteger toBigInteger(Object value) {
return toBigInteger(value, null);
}
public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) {
return convertQuietly(BigDecimal.class, value, defaultValue);
}
public static BigDecimal toBigDecimal(Object value) {
return toBigDecimal(value, null);
}
public static Date toDate(Object value, Date defaultValue) {
return convertQuietly(Date.class, value, defaultValue);
}
public static LocalDateTime toLocalDateTime(Object value, LocalDateTime defaultValue) {
return convertQuietly(LocalDateTime.class, value, defaultValue);
}
public static LocalDateTime toLocalDateTime(Object value) {
return toLocalDateTime(value, null);
}
public static Date toInstant(Object value, Date defaultValue) {
return convertQuietly(Instant.class, value, defaultValue);
}
public static Date toDate(Object value) {
return toDate(value, null);
}
@SuppressWarnings("unchecked")
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue) {
return (E) (new EnumConverter(clazz)).convertQuietly(value, defaultValue);
}
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value) {
return toEnum(clazz, value, null);
}
public static Collection<?> toCollection(Class<?> collectionType, Class<?> elementType, Object value) {
return new CollectionConverter(collectionType, elementType).convert(value, null);
}
public static List<?> toList(Object value) {
return convert(List.class, value);
}
@SuppressWarnings("unchecked")
public static <T> List<T> toList(Class<T> elementType, Object value) {
return (List<T>) toCollection(ArrayList.class, elementType, value);
}
@SuppressWarnings("unchecked")
public static <T> Set<T> toSet(Class<T> elementType, Object value) {
return (Set<T>) toCollection(HashSet.class, elementType, value);
}
@SuppressWarnings("unchecked")
public static <K, V> Map<K, V> toMap(Class<K> keyType, Class<V> valueType, Object value) {
return (Map<K, V>) new MapConverter(HashMap.class, keyType, valueType).convert(value, null);
}
public static <T> T convertByClassName(String className, Object value) throws ConvertException{
return convert(ClassUtil.loadClass(className), value);
}
public static <T> T convert(Class<T> type, Object value) throws ConvertException{
return convert((Type)type, value);
}
public static <T> T convert(TypeReference<T> reference, Object value) throws ConvertException{
return convert(reference.getType(), value, null);
}
public static <T> T convert(Type type, Object value) throws ConvertException{
return convert(type, value, null);
}
public static <T> T convert(Class<T> type, Object value, T defaultValue) throws ConvertException {
return convert((Type)type, value, defaultValue);
}
public static <T> T convert(Type type, Object value, T defaultValue) throws ConvertException {
return convertWithCheck(type, value, defaultValue, false);
}
public static <T> T convertQuietly(Type type, Object value) {
return convertQuietly(type, value, null);
}
public static <T> T convertQuietly(Type type, Object value, T defaultValue) {
return convertWithCheck(type, value, defaultValue, true);
}
public static <T> T convertWithCheck(Type type, Object value, T defaultValue, boolean quietly) {
final ConverterRegistry registry = ConverterRegistry.getInstance();
try {
return registry.convert(type, value, defaultValue);
} catch (Exception e) {
if(quietly){
return defaultValue;
}
throw e;
}
}
public static String toSBC(String input) {
return toSBC(input, null);
}
public static String toSBC(String input, Set<Character> notConvertSet) {
final char[] c = input.toCharArray();
for (int i = 0; i < c.length; i++) {
if (null != notConvertSet && notConvertSet.contains(c[i])) {
continue;
}
if (c[i] == ' ') {
c[i] = '\u3000';
} else if (c[i] < '\177') {
c[i] = (char) (c[i] + 65248);
}
}
return new String(c);
}
public static String toDBC(String input) {
return toDBC(input, null);
}
public static String toDBC(String text, Set<Character> notConvertSet) {
if(StrUtil.isBlank(text)) {
return text;
}
final char[] c = text.toCharArray();
for (int i = 0; i < c.length; i++) {
if (null != notConvertSet && notConvertSet.contains(c[i])) {
continue;
}
if (c[i] == '\u3000' || c[i] == '\u00a0' || c[i] == '\u2007' || c[i] == '\u202F') {
c[i] = ' ';
} else if (c[i] > '\uFF00' && c[i] < '\uFF5F') {
c[i] = (char) (c[i] - 65248);
}
}
return new String(c);
}
public static String toHex(String str, Charset charset) {
return HexUtil.encodeHexStr(str, charset);
}
public static String toHex(byte[] bytes) {
return HexUtil.encodeHexStr(bytes);
}
public static byte[] hexToBytes(String src) {
return HexUtil.decodeHex(src.toCharArray());
}
public static String hexToStr(String hexStr, Charset charset) {
return HexUtil.decodeHexStr(hexStr, charset);
}
public static String strToUnicode(String strText) {
return UnicodeUtil.toUnicode(strText);
}
public static String unicodeToStr(String unicode) {
return UnicodeUtil.toString(unicode);
}
public static String convertCharset(String str, String sourceCharset, String destCharset) {
if (StrUtil.hasBlank(str, sourceCharset, destCharset)) {
return str;
}
return CharsetUtil.convert(str, sourceCharset, destCharset);
}
public static long convertTime(long sourceDuration, TimeUnit sourceUnit, TimeUnit destUnit) {
Assert.notNull(sourceUnit, "sourceUnit is null !");
Assert.notNull(destUnit, "destUnit is null !");
return destUnit.convert(sourceDuration, sourceUnit);
}
public static Class<?> wrap(Class<?> clazz) {
return BasicType.wrap(clazz);
}
public static Class<?> unWrap(Class<?> clazz) {
return BasicType.unWrap(clazz);
}
public static String numberToWord(Number number) {
return NumberWordFormatter.format(number);
}
public static String numberToSimple(Number number) {
return NumberWordFormatter.formatSimple(number.longValue());
}
public static String numberToChinese(double number, boolean isUseTraditional) {
return NumberChineseFormatter.format(number, isUseTraditional);
}
public static int chineseToNumber(String number){
return NumberChineseFormatter.chineseToNumber(number);
}
public static String digitToChinese(Number n) {
if(null == n) {
return "零";
}
return NumberChineseFormatter.format(n.doubleValue(), true, true);
}
public static byte intToByte(int intValue) {
return (byte) intValue;
}
public static int byteToUnsignedInt(byte byteValue) {
return byteValue & 0xFF;
}
public static short bytesToShort(byte[] bytes) {
return ByteUtil.bytesToShort(bytes);
}
public static byte[] shortToBytes(short shortValue) {
return ByteUtil.shortToBytes(shortValue);
}
public static int bytesToInt(byte[] bytes) {
return ByteUtil.bytesToInt(bytes);
}
public static byte[] intToBytes(int intValue) {
return ByteUtil.intToBytes(intValue);
}
public static byte[] longToBytes(long longValue) {
return ByteUtil.longToBytes(longValue);
}
public static long bytesToLong(byte[] bytes) {
return ByteUtil.bytesToLong(bytes);
}
}
ConverterRegistry
package cn.hutool.core.convert;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.impl.ArrayConverter;
import cn.hutool.core.convert.impl.AtomicBooleanConverter;
import cn.hutool.core.convert.impl.AtomicIntegerArrayConverter;
import cn.hutool.core.convert.impl.AtomicLongArrayConverter;
import cn.hutool.core.convert.impl.AtomicReferenceConverter;
import cn.hutool.core.convert.impl.BeanConverter;
import cn.hutool.core.convert.impl.BooleanConverter;
import cn.hutool.core.convert.impl.CalendarConverter;
import cn.hutool.core.convert.impl.CharacterConverter;
import cn.hutool.core.convert.impl.CharsetConverter;
import cn.hutool.core.convert.impl.ClassConverter;
import cn.hutool.core.convert.impl.CollectionConverter;
import cn.hutool.core.convert.impl.CurrencyConverter;
import cn.hutool.core.convert.impl.DateConverter;
import cn.hutool.core.convert.impl.DurationConverter;
import cn.hutool.core.convert.impl.EnumConverter;
import cn.hutool.core.convert.impl.LocaleConverter;
import cn.hutool.core.convert.impl.MapConverter;
import cn.hutool.core.convert.impl.NumberConverter;
import cn.hutool.core.convert.impl.OptionalConverter;
import cn.hutool.core.convert.impl.PathConverter;
import cn.hutool.core.convert.impl.PeriodConverter;
import cn.hutool.core.convert.impl.PrimitiveConverter;
import cn.hutool.core.convert.impl.ReferenceConverter;
import cn.hutool.core.convert.impl.StackTraceElementConverter;
import cn.hutool.core.convert.impl.StringConverter;
import cn.hutool.core.convert.impl.TemporalAccessorConverter;
import cn.hutool.core.convert.impl.TimeZoneConverter;
import cn.hutool.core.convert.impl.URIConverter;
import cn.hutool.core.convert.impl.URLConverter;
import cn.hutool.core.convert.impl.UUIDConverter;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.util.ClassUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.ServiceLoaderUtil;
import cn.hutool.core.util.TypeUtil;
import java.io.Serializable;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URI;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.Period;
import java.time.ZonedDateTime;
import java.time.temporal.TemporalAccessor;
import java.util.Calendar;
import java.util.Collection;
import java.util.Currency;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.TimeZone;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicIntegerArray;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicLongArray;
import java.util.concurrent.atomic.AtomicReference;
public class ConverterRegistry implements Serializable {
private static final long serialVersionUID = 1L;
private Map<Type, Converter<?>> defaultConverterMap;
private volatile Map<Type, Converter<?>> customConverterMap;
private static class SingletonHolder {
private static final ConverterRegistry INSTANCE = new ConverterRegistry();
}
public static ConverterRegistry getInstance() {
return SingletonHolder.INSTANCE;
}
public ConverterRegistry putCustom(Type type, Class<? extends Converter<?>> converterClass) {
return putCustom(type, ReflectUtil.newInstance(converterClass));
}
public ConverterRegistry putCustom(Type type, Converter<?> converter) {
if (null == customConverterMap) {
synchronized (this) {
if (null == customConverterMap) {
customConverterMap = new ConcurrentHashMap<>();
}
}
}
customConverterMap.put(type, converter);
return this;
}
public ConverterRegistry() {
defaultConverter();
putCustomBySpi();
}
private void putCustomBySpi() {
ServiceLoaderUtil.load(Converter.class).forEach(converter -> {
try {
Type type = TypeUtil.getTypeArgument(ClassUtil.getClass(converter));
if(null != type){
putCustom(type, converter);
}
} catch (Exception e) {
}
});
}
public <T> Converter<T> getConverter(Type type, boolean isCustomFirst) {
Converter<T> converter;
if (isCustomFirst) {
converter = this.getCustomConverter(type);
if (null == converter) {
converter = this.getDefaultConverter(type);
}
} else {
converter = this.getDefaultConverter(type);
if (null == converter) {
converter = this.getCustomConverter(type);
}
}
return converter;
}
@SuppressWarnings("unchecked")
public <T> Converter<T> getDefaultConverter(Type type) {
return (null == defaultConverterMap) ? null : (Converter<T>) defaultConverterMap.get(type);
}
@SuppressWarnings("unchecked")
public <T> Converter<T> getCustomConverter(Type type) {
return (null == customConverterMap) ? null : (Converter<T>) customConverterMap.get(type);
}
@SuppressWarnings("unchecked")
public <T> T convert(Type type, Object value, T defaultValue, boolean isCustomFirst) throws ConvertException {
if (TypeUtil.isUnknown(type) && null == defaultValue) {
return (T) value;
}
if (ObjectUtil.isNull(value)) {
return defaultValue;
}
if (TypeUtil.isUnknown(type)) {
type = defaultValue.getClass();
}
if (type instanceof TypeReference) {
type = ((TypeReference<?>) type).getType();
}
final Converter<T> converter = getConverter(type, isCustomFirst);
if (null != converter) {
return converter.convert(value, defaultValue);
}
Class<T> rowType = (Class<T>) TypeUtil.getClass(type);
if (null == rowType) {
if (null != defaultValue) {
rowType = (Class<T>) defaultValue.getClass();
} else {
return (T) value;
}
}
final T result = convertSpecial(type, rowType, value, defaultValue);
if (null != result) {
return result;
}
if (BeanUtil.isBean(rowType)) {
return new BeanConverter<T>(type).convert(value, defaultValue);
}
throw new ConvertException("Can not Converter from [{}] to [{}]", value.getClass().getName(), type.getTypeName());
}
public <T> T convert(Type type, Object value, T defaultValue) throws ConvertException {
return convert(type, value, defaultValue, true);
}
public <T> T convert(Type type, Object value) throws ConvertException {
return convert(type, value, null);
}
@SuppressWarnings("unchecked")
private <T> T convertSpecial(Type type, Class<T> rowType, Object value, T defaultValue) {
if (null == rowType) {
return null;
}
if (Collection.class.isAssignableFrom(rowType)) {
final CollectionConverter collectionConverter = new CollectionConverter(type);
return (T) collectionConverter.convert(value, (Collection<?>) defaultValue);
}
if (Map.class.isAssignableFrom(rowType)) {
final MapConverter mapConverter = new MapConverter(type);
return (T) mapConverter.convert(value, (Map<?, ?>) defaultValue);
}
if (rowType.isInstance(value)) {
return (T) value;
}
if (rowType.isEnum()) {
return (T) new EnumConverter(rowType).convert(value, defaultValue);
}
if (rowType.isArray()) {
final ArrayConverter arrayConverter = new ArrayConverter(rowType);
return (T) arrayConverter.convert(value, defaultValue);
}
return null;
}
private ConverterRegistry defaultConverter() {
defaultConverterMap = new ConcurrentHashMap<>();
defaultConverterMap.put(int.class, new PrimitiveConverter(int.class));
defaultConverterMap.put(long.class, new PrimitiveConverter(long.class));
defaultConverterMap.put(byte.class, new PrimitiveConverter(byte.class));
defaultConverterMap.put(short.class, new PrimitiveConverter(short.class));
defaultConverterMap.put(float.class, new PrimitiveConverter(float.class));
defaultConverterMap.put(double.class, new PrimitiveConverter(double.class));
defaultConverterMap.put(char.class, new PrimitiveConverter(char.class));
defaultConverterMap.put(boolean.class, new PrimitiveConverter(boolean.class));
defaultConverterMap.put(Number.class, new NumberConverter());
defaultConverterMap.put(Integer.class, new NumberConverter(Integer.class));
defaultConverterMap.put(AtomicInteger.class, new NumberConverter(AtomicInteger.class));
defaultConverterMap.put(Long.class, new NumberConverter(Long.class));
defaultConverterMap.put(AtomicLong.class, new NumberConverter(AtomicLong.class));
defaultConverterMap.put(Byte.class, new NumberConverter(Byte.class));
defaultConverterMap.put(Short.class, new NumberConverter(Short.class));
defaultConverterMap.put(Float.class, new NumberConverter(Float.class));
defaultConverterMap.put(Double.class, new NumberConverter(Double.class));
defaultConverterMap.put(Character.class, new CharacterConverter());
defaultConverterMap.put(Boolean.class, new BooleanConverter());
defaultConverterMap.put(AtomicBoolean.class, new AtomicBooleanConverter());
defaultConverterMap.put(BigDecimal.class, new NumberConverter(BigDecimal.class));
defaultConverterMap.put(BigInteger.class, new NumberConverter(BigInteger.class));
defaultConverterMap.put(CharSequence.class, new StringConverter());
defaultConverterMap.put(String.class, new StringConverter());
defaultConverterMap.put(URI.class, new URIConverter());
defaultConverterMap.put(URL.class, new URLConverter());
defaultConverterMap.put(Calendar.class, new CalendarConverter());
defaultConverterMap.put(java.util.Date.class, new DateConverter(java.util.Date.class));
defaultConverterMap.put(DateTime.class, new DateConverter(DateTime.class));
defaultConverterMap.put(java.sql.Date.class, new DateConverter(java.sql.Date.class));
defaultConverterMap.put(java.sql.Time.class, new DateConverter(java.sql.Time.class));
defaultConverterMap.put(java.sql.Timestamp.class, new DateConverter(java.sql.Timestamp.class));
defaultConverterMap.put(TemporalAccessor.class, new TemporalAccessorConverter(Instant.class));
defaultConverterMap.put(Instant.class, new TemporalAccessorConverter(Instant.class));
defaultConverterMap.put(LocalDateTime.class, new TemporalAccessorConverter(LocalDateTime.class));
defaultConverterMap.put(LocalDate.class, new TemporalAccessorConverter(LocalDate.class));
defaultConverterMap.put(LocalTime.class, new TemporalAccessorConverter(LocalTime.class));
defaultConverterMap.put(ZonedDateTime.class, new TemporalAccessorConverter(ZonedDateTime.class));
defaultConverterMap.put(OffsetDateTime.class, new TemporalAccessorConverter(OffsetDateTime.class));
defaultConverterMap.put(OffsetTime.class, new TemporalAccessorConverter(OffsetTime.class));
defaultConverterMap.put(Period.class, new PeriodConverter());
defaultConverterMap.put(Duration.class, new DurationConverter());
defaultConverterMap.put(WeakReference.class, new ReferenceConverter(WeakReference.class));
defaultConverterMap.put(SoftReference.class, new ReferenceConverter(SoftReference.class));
defaultConverterMap.put(AtomicReference.class, new AtomicReferenceConverter());
defaultConverterMap.put(AtomicIntegerArray.class, new AtomicIntegerArrayConverter());
defaultConverterMap.put(AtomicLongArray.class, new AtomicLongArrayConverter());
defaultConverterMap.put(Class.class, new ClassConverter());
defaultConverterMap.put(TimeZone.class, new TimeZoneConverter());
defaultConverterMap.put(Locale.class, new LocaleConverter());
defaultConverterMap.put(Charset.class, new CharsetConverter());
defaultConverterMap.put(Path.class, new PathConverter());
defaultConverterMap.put(Currency.class, new CurrencyConverter());
defaultConverterMap.put(UUID.class, new UUIDConverter());
defaultConverterMap.put(StackTraceElement.class, new StackTraceElementConverter());
defaultConverterMap.put(Optional.class, new OptionalConverter());
return this;
}
}