diff --git a/src/main/java/com/cedarsoftware/util/Converter.java b/src/main/java/com/cedarsoftware/util/Converter.java index 1dd8a2f5..8b38f291 100644 --- a/src/main/java/com/cedarsoftware/util/Converter.java +++ b/src/main/java/com/cedarsoftware/util/Converter.java @@ -16,7 +16,6 @@ import com.cedarsoftware.util.convert.CommonValues; import com.cedarsoftware.util.convert.Convert; -import com.cedarsoftware.util.convert.ConverterOptions; import com.cedarsoftware.util.convert.DefaultConverterOptions; /** @@ -75,16 +74,7 @@ private Converter() { } public static T convert(Object fromInstance, Class toType) { return instance.convert(fromInstance, toType); } - - /** - * Allows you to specify (per each call) different conversion options. Useful so you don't have - * to recreate the instance of Converter that is out there for every configuration option. Just - * provide a different set of ConverterOptions on the call itself. - */ - public static T convert(Object fromInstance, Class toType, ConverterOptions options) { - return instance.convert(fromInstance, toType, options); - } - + /** * Check to see if a conversion from type to another type is supported (may use inheritance via super classes/interfaces). * diff --git a/src/main/java/com/cedarsoftware/util/convert/AtomicBooleanConversions.java b/src/main/java/com/cedarsoftware/util/convert/AtomicBooleanConversions.java index 16558852..b527fd71 100644 --- a/src/main/java/com/cedarsoftware/util/convert/AtomicBooleanConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/AtomicBooleanConversions.java @@ -23,72 +23,73 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class AtomicBooleanConversions { +final class AtomicBooleanConversions { private AtomicBooleanConversions() {} - static Byte toByte(Object from, Converter converter, ConverterOptions options) { + static Byte toByte(Object from, Converter converter) { AtomicBoolean b = (AtomicBoolean) from; return b.get() ? CommonValues.BYTE_ONE : CommonValues.BYTE_ZERO; } - static Short toShort(Object from, Converter converter, ConverterOptions options) { + static Short toShort(Object from, Converter converter) { AtomicBoolean b = (AtomicBoolean) from; return b.get() ? CommonValues.SHORT_ONE : CommonValues.SHORT_ZERO; } - static Integer toInteger(Object from, Converter converter, ConverterOptions options) { + static Integer toInteger(Object from, Converter converter) { AtomicBoolean b = (AtomicBoolean) from; return b.get() ? CommonValues.INTEGER_ONE : CommonValues.INTEGER_ZERO; } - static Long toLong(Object from, Converter converter, ConverterOptions options) { + static Long toLong(Object from, Converter converter) { AtomicBoolean b = (AtomicBoolean) from; return b.get() ? CommonValues.LONG_ONE : CommonValues.LONG_ZERO; } - static Float toFloat(Object from, Converter converter, ConverterOptions options) { + static Float toFloat(Object from, Converter converter) { AtomicBoolean b = (AtomicBoolean) from; return b.get() ? CommonValues.FLOAT_ONE : CommonValues.FLOAT_ZERO; } - static Double toDouble(Object from, Converter converter, ConverterOptions options) { + static Double toDouble(Object from, Converter converter) { AtomicBoolean b = (AtomicBoolean) from; return b.get() ? CommonValues.DOUBLE_ONE : CommonValues.DOUBLE_ZERO; } - static boolean toBoolean(Object from, Converter converter, ConverterOptions options) { + static boolean toBoolean(Object from, Converter converter) { AtomicBoolean b = (AtomicBoolean) from; return b.get(); } - static AtomicBoolean toAtomicBoolean(Object from, Converter converter, ConverterOptions options) { + static AtomicBoolean toAtomicBoolean(Object from, Converter converter) { AtomicBoolean b = (AtomicBoolean) from; return new AtomicBoolean(b.get()); } - static AtomicInteger toAtomicInteger(Object from, Converter converter, ConverterOptions options) { + static AtomicInteger toAtomicInteger(Object from, Converter converter) { AtomicBoolean b = (AtomicBoolean) from; return b.get() ? new AtomicInteger(1) : new AtomicInteger (0); } - static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) { + static AtomicLong toAtomicLong(Object from, Converter converter) { AtomicBoolean b = (AtomicBoolean) from; return b.get() ? new AtomicLong(1) : new AtomicLong(0); } - static Character toCharacter(Object from, Converter converter, ConverterOptions options) { + static Character toCharacter(Object from, Converter converter) { AtomicBoolean b = (AtomicBoolean) from; + ConverterOptions options = converter.getOptions(); return b.get() ? options.trueChar() : options.falseChar(); } - static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) { + static BigDecimal toBigDecimal(Object from, Converter converter) { AtomicBoolean b = (AtomicBoolean) from; return b.get() ? BigDecimal.ONE : BigDecimal.ZERO; } - public static BigInteger toBigInteger(Object from, Converter converter, ConverterOptions options) { + public static BigInteger toBigInteger(Object from, Converter converter) { AtomicBoolean b = (AtomicBoolean) from; return b.get() ? BigInteger.ONE : BigInteger.ZERO; } diff --git a/src/main/java/com/cedarsoftware/util/convert/BooleanConversions.java b/src/main/java/com/cedarsoftware/util/convert/BooleanConversions.java index 2d34f3b0..4ed6248f 100644 --- a/src/main/java/com/cedarsoftware/util/convert/BooleanConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/BooleanConversions.java @@ -24,65 +24,66 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class BooleanConversions { +final class BooleanConversions { private BooleanConversions() {} - static Byte toByte(Object from, Converter converter, ConverterOptions options) { + static Byte toByte(Object from, Converter converter) { Boolean b = (Boolean) from; return b ? CommonValues.BYTE_ONE : CommonValues.BYTE_ZERO; } - static Short toShort(Object from, Converter converter, ConverterOptions options) { + static Short toShort(Object from, Converter converter) { Boolean b = (Boolean) from; return b ? CommonValues.SHORT_ONE : CommonValues.SHORT_ZERO; } - static Integer toInteger(Object from, Converter converter, ConverterOptions options) { + static Integer toInteger(Object from, Converter converter) { Boolean b = (Boolean) from; return b ? CommonValues.INTEGER_ONE : CommonValues.INTEGER_ZERO; } - static AtomicInteger toAtomicInteger(Object from, Converter converter, ConverterOptions options) { + static AtomicInteger toAtomicInteger(Object from, Converter converter) { Boolean b = (Boolean) from; return new AtomicInteger(b ? 1 : 0); } - static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) { + static AtomicLong toAtomicLong(Object from, Converter converter) { Boolean b = (Boolean) from; return new AtomicLong(b ? 1 : 0); } - static AtomicBoolean toAtomicBoolean(Object from, Converter converter, ConverterOptions options) { + static AtomicBoolean toAtomicBoolean(Object from, Converter converter) { Boolean b = (Boolean) from; return new AtomicBoolean(b); } - static Long toLong(Object from, Converter converter, ConverterOptions options) { + static Long toLong(Object from, Converter converter) { Boolean b = (Boolean) from; return b.booleanValue() ? CommonValues.LONG_ONE : CommonValues.LONG_ZERO; } - static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) { + static BigDecimal toBigDecimal(Object from, Converter converter) { Boolean b = (Boolean)from; return b ? BigDecimal.ONE : BigDecimal.ZERO; } - static BigInteger toBigInteger(Object from, Converter converter, ConverterOptions options) { + static BigInteger toBigInteger(Object from, Converter converter) { return ((Boolean)from) ? BigInteger.ONE : BigInteger.ZERO; } - static Float toFloat(Object from, Converter converter, ConverterOptions options) { + static Float toFloat(Object from, Converter converter) { Boolean b = (Boolean) from; return b ? CommonValues.FLOAT_ONE : CommonValues.FLOAT_ZERO; } - static Double toDouble(Object from, Converter converter, ConverterOptions options) { + static Double toDouble(Object from, Converter converter) { Boolean b = (Boolean) from; return b ? CommonValues.DOUBLE_ONE : CommonValues.DOUBLE_ZERO; } - static char toCharacter(Object from, Converter converter, ConverterOptions options) { + static char toCharacter(Object from, Converter converter) { Boolean b = (Boolean) from; + ConverterOptions options = converter.getOptions(); return b ? options.trueChar() : options.falseChar(); } } diff --git a/src/main/java/com/cedarsoftware/util/convert/ByteArrayConversions.java b/src/main/java/com/cedarsoftware/util/convert/ByteArrayConversions.java index aa3c8ef0..dbd3663f 100644 --- a/src/main/java/com/cedarsoftware/util/convert/ByteArrayConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/ByteArrayConversions.java @@ -1,46 +1,53 @@ package com.cedarsoftware.util.convert; -import com.cedarsoftware.util.StringUtilities; - import java.nio.ByteBuffer; import java.nio.CharBuffer; -import java.util.concurrent.atomic.AtomicInteger; -public final class ByteArrayConversions { +import com.cedarsoftware.util.StringUtilities; + +/** + * @author Kenny Partlow (kpartlow@gmail.com) + *
+ * Copyright (c) Cedar Software LLC + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * License + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +final class ByteArrayConversions { private ByteArrayConversions() {} - static String toString(Object from, ConverterOptions options) { + static String toString(Object from, Converter converter) { byte[] bytes = (byte[])from; - return (bytes == null) ? StringUtilities.EMPTY : new String(bytes, options.getCharset()); + return (bytes == null) ? StringUtilities.EMPTY : new String(bytes, converter.getOptions().getCharset()); } - static ByteBuffer toByteBuffer(Object from) { - return ByteBuffer.wrap((byte[])from); + static ByteBuffer toByteBuffer(Object from, Converter converter) { + return ByteBuffer.wrap((byte[]) from); } - static String toString(Object from, Converter converter, ConverterOptions options) { - return toString(from, options); + static CharBuffer toCharBuffer(Object from, Converter converter) { + return CharBuffer.wrap(toString(from, converter)); } - static ByteBuffer toByteBuffer(Object from, Converter converter, ConverterOptions options) { - return toByteBuffer(from); + static char[] toCharArray(Object from, Converter converter) { + return toString(from, converter).toCharArray(); } - static CharBuffer toCharBuffer(Object from, Converter converter, ConverterOptions options) { - return CharBuffer.wrap(toString(from, options)); + static StringBuffer toStringBuffer(Object from, Converter converter) { + return new StringBuffer(toString(from, converter)); } - static char[] toCharArray(Object from, Converter converter, ConverterOptions options) { - return toString(from, options).toCharArray(); + static StringBuilder toStringBuilder(Object from, Converter converter) { + return new StringBuilder(toString(from, converter)); } - - static StringBuffer toStringBuffer(Object from, Converter converter, ConverterOptions options) { - return new StringBuffer(toString(from, options)); - } - - static StringBuilder toStringBuilder(Object from, Converter converter, ConverterOptions options) { - return new StringBuilder(toString(from, options)); - } - } diff --git a/src/main/java/com/cedarsoftware/util/convert/ByteBufferConversions.java b/src/main/java/com/cedarsoftware/util/convert/ByteBufferConversions.java index b442852e..807cf1f5 100644 --- a/src/main/java/com/cedarsoftware/util/convert/ByteBufferConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/ByteBufferConversions.java @@ -5,20 +5,42 @@ import static com.cedarsoftware.util.ArrayUtilities.EMPTY_BYTE_ARRAY; -public final class ByteBufferConversions { +/** + * @author Kenny Partlow (kpartlow@gmail.com) + *
+ * Copyright (c) Cedar Software LLC + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * License + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +final class ByteBufferConversions { private ByteBufferConversions() {} + + static CharBuffer toCharBuffer(Object from, Converter converter) { + ByteBuffer buffer = toByteBuffer(from, converter); + return converter.getOptions().getCharset().decode(buffer); + } - static ByteBuffer asReadOnlyBuffer(Object from) { + static ByteBuffer toByteBuffer(Object from, Converter converter) { // Create a readonly buffer so we aren't changing // the original buffers mark and position when // working with this buffer. This could be inefficient // if constantly fed with writeable buffers so should be documented - return ((ByteBuffer)from).asReadOnlyBuffer(); + return ((ByteBuffer) from).asReadOnlyBuffer(); } - static byte[] toByteArray(Object from) { - ByteBuffer buffer = asReadOnlyBuffer(from); + static byte[] toByteArray(Object from, Converter converter) { + ByteBuffer buffer = toByteBuffer(from, converter); if (buffer == null || !buffer.hasRemaining()) { return EMPTY_BYTE_ARRAY; @@ -29,37 +51,19 @@ static byte[] toByteArray(Object from) { return bytes; } - static CharBuffer toCharBuffer(Object from, ConverterOptions options) { - ByteBuffer buffer = asReadOnlyBuffer(from); - return options.getCharset().decode(buffer); - } - - static CharBuffer toCharBuffer(Object from, Converter converter, ConverterOptions options) { - return toCharBuffer(from, options); - } - - static ByteBuffer toByteBuffer(Object from, Converter converter, ConverterOptions options) { - return asReadOnlyBuffer(from); + static String toString(Object from, Converter converter) { + return toCharBuffer(from, converter).toString(); } - static byte[] toByteArray(Object from, Converter converter, ConverterOptions options) { - return toByteArray(from); + static char[] toCharArray(Object from, Converter converter) { + return CharBufferConversions.toCharArray(toCharBuffer(from, converter), converter); } - static String toString(Object from, Converter converter, ConverterOptions options) { - return toCharBuffer(from, options).toString(); + static StringBuffer toStringBuffer(Object from, Converter converter) { + return new StringBuffer(toCharBuffer(from, converter)); } - static char[] toCharArray(Object from, Converter converter, ConverterOptions options) { - return CharBufferConversions.toCharArray(toCharBuffer(from, options)); + static StringBuilder toStringBuilder(Object from, Converter converter) { + return new StringBuilder(toCharBuffer(from, converter)); } - - static StringBuffer toStringBuffer(Object from, Converter converter, ConverterOptions options) { - return new StringBuffer(toCharBuffer(from, options)); - } - - static StringBuilder toStringBuilder(Object from, Converter converter, ConverterOptions options) { - return new StringBuilder(toCharBuffer(from, options)); - } - } diff --git a/src/main/java/com/cedarsoftware/util/convert/CalendarConversions.java b/src/main/java/com/cedarsoftware/util/convert/CalendarConversions.java index c418f38b..437433f5 100644 --- a/src/main/java/com/cedarsoftware/util/convert/CalendarConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/CalendarConversions.java @@ -30,97 +30,80 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class CalendarConversions { +final class CalendarConversions { private CalendarConversions() {} - static Date toDate(Object from) { - return ((Calendar)from).getTime(); - } - - static long toLong(Object from) { - return toDate(from).getTime(); - } - - static Instant toInstant(Object from) { - Calendar calendar = (Calendar)from; - return calendar.toInstant(); - } - - static ZonedDateTime toZonedDateTime(Object from, ConverterOptions options) { + static ZonedDateTime toZonedDateTime(Object from, Converter converter) { Calendar calendar = (Calendar)from; return calendar.toInstant().atZone(calendar.getTimeZone().toZoneId()); } - static ZonedDateTime toZonedDateTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options); - } - - static Long toLong(Object from, Converter converter, ConverterOptions options) { - return toLong(from); + static Long toLong(Object from, Converter converter) { + return ((Calendar) from).getTime().getTime(); } - static double toDouble(Object from, Converter converter, ConverterOptions options) { - return (double)toLong(from); + static double toDouble(Object from, Converter converter) { + return (double)toLong(from, converter); } - - - static Date toDate(Object from, Converter converter, ConverterOptions options) { - return toDate(from); + + static Date toDate(Object from, Converter converter) { + return ((Calendar) from).getTime(); } - static java.sql.Date toSqlDate(Object from, Converter converter, ConverterOptions options) { - return new java.sql.Date(toLong(from)); + static java.sql.Date toSqlDate(Object from, Converter converter) { + return new java.sql.Date(((Calendar) from).getTime().getTime()); } - static Timestamp toTimestamp(Object from, Converter converter, ConverterOptions options) { - return new Timestamp(toLong(from)); + static Timestamp toTimestamp(Object from, Converter converter) { + return new Timestamp(((Calendar) from).getTime().getTime()); } - static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) { - return new AtomicLong(toLong(from)); + static AtomicLong toAtomicLong(Object from, Converter converter) { + return new AtomicLong(((Calendar) from).getTime().getTime()); } - static Instant toInstant(Object from, Converter converter, ConverterOptions options) { - return toInstant(from); + static Instant toInstant(Object from, Converter converter) { + Calendar calendar = (Calendar) from; + return calendar.toInstant(); } - static LocalDateTime toLocalDateTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalDateTime(); + static LocalDateTime toLocalDateTime(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalDateTime(); } - static LocalDate toLocalDate(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalDate(); + static LocalDate toLocalDate(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalDate(); } - static LocalTime toLocalTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalTime(); + static LocalTime toLocalTime(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalTime(); } - static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) { - return BigDecimal.valueOf(toLong(from)); + static BigDecimal toBigDecimal(Object from, Converter converter) { + return BigDecimal.valueOf(((Calendar) from).getTime().getTime()); } - static BigInteger toBigInteger(Object from, Converter converter, ConverterOptions options) { - return BigInteger.valueOf(toLong(from)); + static BigInteger toBigInteger(Object from, Converter converter) { + return BigInteger.valueOf(((Calendar) from).getTime().getTime()); } - static Calendar clone(Object from, Converter converter, ConverterOptions options) { + static Calendar clone(Object from, Converter converter) { Calendar calendar = (Calendar)from; // mutable class, so clone it. return (Calendar)calendar.clone(); } - static Calendar create(long epochMilli, ConverterOptions options) { - Calendar cal = Calendar.getInstance(options.getTimeZone()); + static Calendar create(long epochMilli, Converter converter) { + Calendar cal = Calendar.getInstance(converter.getOptions().getTimeZone()); cal.clear(); cal.setTimeInMillis(epochMilli); return cal; } - static String toString(Object from, Converter converter, ConverterOptions options) { + static String toString(Object from, Converter converter) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); - simpleDateFormat.setTimeZone(options.getTimeZone()); + simpleDateFormat.setTimeZone(converter.getOptions().getTimeZone()); return simpleDateFormat.format(((Calendar) from).getTime()); } } diff --git a/src/main/java/com/cedarsoftware/util/convert/CharArrayConversions.java b/src/main/java/com/cedarsoftware/util/convert/CharArrayConversions.java index 5ae4e702..7eed9bf3 100644 --- a/src/main/java/com/cedarsoftware/util/convert/CharArrayConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/CharArrayConversions.java @@ -4,53 +4,57 @@ import java.nio.CharBuffer; import java.util.Arrays; -public final class CharArrayConversions { +/** + * @author Kenny Partlow (kpartlow@gmail.com) + *
+ * Copyright (c) Cedar Software LLC + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * License + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +final class CharArrayConversions { private CharArrayConversions() {} - - static String toString(Object from) { - char[] chars = (char[])from; + + static ByteBuffer toByteBuffer(Object from, Converter converter) { + return converter.getOptions().getCharset().encode(toCharBuffer(from, converter)); + } + + static String toString(Object from, Converter converter) { + char[] chars = (char[]) from; return new String(chars); } - static CharBuffer toCharBuffer(Object from) { - char[] chars = (char[])from; + static CharBuffer toCharBuffer(Object from, Converter converter) { + char[] chars = (char[]) from; return CharBuffer.wrap(chars); } - static ByteBuffer toByteBuffer(Object from, ConverterOptions options) { - return options.getCharset().encode(toCharBuffer(from)); - } - - - static String toString(Object from, Converter converter, ConverterOptions options) { - return toString(from); - } - - static CharBuffer toCharBuffer(Object from, Converter converter, ConverterOptions options) { - return toCharBuffer(from); - } - - static StringBuffer toStringBuffer(Object from, Converter converter, ConverterOptions options) { - return new StringBuffer(toCharBuffer(from)); - } - - static StringBuilder toStringBuilder(Object from, Converter converter, ConverterOptions options) { - return new StringBuilder(toCharBuffer(from)); + static StringBuffer toStringBuffer(Object from, Converter converter) { + return new StringBuffer(toCharBuffer(from, converter)); } - static ByteBuffer toByteBuffer(Object from, Converter converter, ConverterOptions options) { - return toByteBuffer(from, options); + static StringBuilder toStringBuilder(Object from, Converter converter) { + return new StringBuilder(toCharBuffer(from, converter)); } - static byte[] toByteArray(Object from, Converter converter, ConverterOptions options) { - ByteBuffer buffer = toByteBuffer(from, options); + static byte[] toByteArray(Object from, Converter converter) { + ByteBuffer buffer = toByteBuffer(from, converter); byte[] byteArray = new byte[buffer.remaining()]; buffer.get(byteArray); return byteArray; } - static char[] toCharArray(Object from, Converter converter, ConverterOptions options) { + static char[] toCharArray(Object from, Converter converter) { char[] chars = (char[])from; if (chars == null) { return null; diff --git a/src/main/java/com/cedarsoftware/util/convert/CharBufferConversions.java b/src/main/java/com/cedarsoftware/util/convert/CharBufferConversions.java index 6ec95821..f9d2264c 100644 --- a/src/main/java/com/cedarsoftware/util/convert/CharBufferConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/CharBufferConversions.java @@ -3,58 +3,66 @@ import java.nio.ByteBuffer; import java.nio.CharBuffer; -import static com.cedarsoftware.util.ArrayUtilities.EMPTY_BYTE_ARRAY; import static com.cedarsoftware.util.ArrayUtilities.EMPTY_CHAR_ARRAY; -public final class CharBufferConversions { +/** + * @author Kenny Partlow (kpartlow@gmail.com) + *
+ * Copyright (c) Cedar Software LLC + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * License + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +final class CharBufferConversions { private CharBufferConversions() {} - static CharBuffer asReadOnlyBuffer(Object from) { + static CharBuffer toCharBuffer(Object from, Converter converter) { // Create a readonly buffer so we aren't changing // the original buffers mark and position when // working with this buffer. This could be inefficient // if constantly fed with writeable buffers so should be documented - return ((CharBuffer)from).asReadOnlyBuffer(); + return ((CharBuffer) from).asReadOnlyBuffer(); } - static char[] toCharArray(Object from) { - CharBuffer buffer = asReadOnlyBuffer(from); - - if (buffer == null || !buffer.hasRemaining()) { - return EMPTY_CHAR_ARRAY; - } - - char[] chars = new char[buffer.remaining()]; - buffer.get(chars); - return chars; + static byte[] toByteArray(Object from, Converter converter) { + return ByteBufferConversions.toByteArray(toByteBuffer(from, converter), converter); } - static CharBuffer toCharBuffer(Object from, Converter converter, ConverterOptions options) { - return asReadOnlyBuffer(from); + static ByteBuffer toByteBuffer(Object from, Converter converter) { + return converter.getOptions().getCharset().encode(toCharBuffer(from, converter)); } - static byte[] toByteArray(Object from, Converter converter, ConverterOptions options) { - return ByteBufferConversions.toByteArray(toByteBuffer(from, converter, options)); + static String toString(Object from, Converter converter) { + return toCharBuffer(from, converter).toString(); } - static ByteBuffer toByteBuffer(Object from, Converter converter, ConverterOptions options) { - return options.getCharset().encode(asReadOnlyBuffer(from)); - } + static char[] toCharArray(Object from, Converter converter) { + CharBuffer buffer = toCharBuffer(from, converter); - static String toString(Object from, Converter converter, ConverterOptions options) { - return asReadOnlyBuffer(from).toString(); - } + if (buffer == null || !buffer.hasRemaining()) { + return EMPTY_CHAR_ARRAY; + } - static char[] toCharArray(Object from, Converter converter, ConverterOptions options) { - return toCharArray(from); + char[] chars = new char[buffer.remaining()]; + buffer.get(chars); + return chars; } - static StringBuffer toStringBuffer(Object from, Converter converter, ConverterOptions options) { - return new StringBuffer(asReadOnlyBuffer(from)); + static StringBuffer toStringBuffer(Object from, Converter converter) { + return new StringBuffer(toCharBuffer(from, converter)); } - static StringBuilder toStringBuilder(Object from, Converter converter, ConverterOptions options) { - return new StringBuilder(asReadOnlyBuffer(from)); + static StringBuilder toStringBuilder(Object from, Converter converter) { + return new StringBuilder(toCharBuffer(from, converter)); } } diff --git a/src/main/java/com/cedarsoftware/util/convert/CharacterArrayConversions.java b/src/main/java/com/cedarsoftware/util/convert/CharacterArrayConversions.java index 500fcdac..e580e445 100644 --- a/src/main/java/com/cedarsoftware/util/convert/CharacterArrayConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/CharacterArrayConversions.java @@ -1,8 +1,34 @@ package com.cedarsoftware.util.convert; -public class CharacterArrayConversions { +/** + * @author Kenny Partlow (kpartlow@gmail.com) + *
+ * Copyright (c) Cedar Software LLC + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * License + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +final class CharacterArrayConversions { - static StringBuilder toStringBuilder(Object from) { + static String toString(Object from, Converter converter) { + Character[] chars = (Character[]) from; + StringBuilder builder = new StringBuilder(chars.length); + for (Character ch : chars) { + builder.append(ch); + } + return builder.toString(); + } + + static StringBuilder toStringBuilder(Object from, Converter converter) { Character[] chars = (Character[]) from; StringBuilder builder = new StringBuilder(chars.length); for (Character ch : chars) { @@ -11,7 +37,7 @@ static StringBuilder toStringBuilder(Object from) { return builder; } - static StringBuffer toStringBuffer(Object from) { + static StringBuffer toStringBuffer(Object from, Converter converter) { Character[] chars = (Character[]) from; StringBuffer buffer = new StringBuffer(chars.length); for (Character ch : chars) { @@ -19,17 +45,4 @@ static StringBuffer toStringBuffer(Object from) { } return buffer; } - - static String toString(Object from, Converter converter, ConverterOptions options) { - return toStringBuilder(from).toString(); - } - - static StringBuilder toStringBuilder(Object from, Converter converter, ConverterOptions options) { - return toStringBuilder(from); - } - - static StringBuffer toStringBuffer(Object from, Converter converter, ConverterOptions options) { - return toStringBuffer(from); - } - } diff --git a/src/main/java/com/cedarsoftware/util/convert/CharacterConversions.java b/src/main/java/com/cedarsoftware/util/convert/CharacterConversions.java index da34b686..c6d5abcf 100644 --- a/src/main/java/com/cedarsoftware/util/convert/CharacterConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/CharacterConversions.java @@ -23,65 +23,61 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class CharacterConversions { +final class CharacterConversions { private CharacterConversions() {} - - static boolean toBoolean(Object from) { - char c = (char) from; - return (c == 1) || (c == 't') || (c == 'T') || (c == '1') || (c == 'y') || (c == 'Y'); - } - - static String toString(Object from, Converter converter, ConverterOptions options) { + + static String toString(Object from, Converter converter) { return "" + from; } - static boolean toBoolean(Object from, Converter converter, ConverterOptions options) { - return toBoolean(from); + static boolean toBoolean(Object from, Converter converter) { + char c = (char) from; + return (c == 1) || (c == 't') || (c == 'T') || (c == '1') || (c == 'y') || (c == 'Y'); } // downcasting -- not always a safe conversino - static byte toByte(Object from, Converter converter, ConverterOptions options) { + static byte toByte(Object from, Converter converter) { return (byte) (char) from; } - static short toShort(Object from, Converter converter, ConverterOptions options) { + static short toShort(Object from, Converter converter) { return (short) (char) from; } - static int toInt(Object from, Converter converter, ConverterOptions options) { + static int toInt(Object from, Converter converter) { return (char) from; } - static long toLong(Object from, Converter converter, ConverterOptions options) { + static long toLong(Object from, Converter converter) { return (char) from; } - static float toFloat(Object from, Converter converter, ConverterOptions options) { + static float toFloat(Object from, Converter converter) { return (char) from; } - static double toDouble(Object from, Converter converter, ConverterOptions options) { + static double toDouble(Object from, Converter converter) { return (char) from; } - static AtomicInteger toAtomicInteger(Object from, Converter converter, ConverterOptions options) { + static AtomicInteger toAtomicInteger(Object from, Converter converter) { return new AtomicInteger((char) from); } - static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) { + static AtomicLong toAtomicLong(Object from, Converter converter) { return new AtomicLong((char) from); } - static AtomicBoolean toAtomicBoolean(Object from, Converter converter, ConverterOptions options) { - return new AtomicBoolean(toBoolean(from)); + static AtomicBoolean toAtomicBoolean(Object from, Converter converter) { + return new AtomicBoolean(toBoolean(from, converter)); } - static BigInteger toBigInteger(Object from, Converter converter, ConverterOptions options) { + static BigInteger toBigInteger(Object from, Converter converter) { return BigInteger.valueOf((char) from); } - static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) { + static BigDecimal toBigDecimal(Object from, Converter converter) { return BigDecimal.valueOf((char) from); } } diff --git a/src/main/java/com/cedarsoftware/util/convert/ClassConversions.java b/src/main/java/com/cedarsoftware/util/convert/ClassConversions.java index b02bc7e8..e83c86c7 100644 --- a/src/main/java/com/cedarsoftware/util/convert/ClassConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/ClassConversions.java @@ -1,10 +1,27 @@ package com.cedarsoftware.util.convert; -public final class ClassConversions { +/** + * @author Kenny Partlow (kpartlow@gmail.com) + *
+ * Copyright (c) Cedar Software LLC + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * License + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +final class ClassConversions { private ClassConversions() {} - static String toString(Object from, Converter converter, ConverterOptions options) { + static String toString(Object from, Converter converter) { Class cls = (Class) from; return cls.getName(); } diff --git a/src/main/java/com/cedarsoftware/util/convert/Convert.java b/src/main/java/com/cedarsoftware/util/convert/Convert.java index 2e451c2a..c994104e 100644 --- a/src/main/java/com/cedarsoftware/util/convert/Convert.java +++ b/src/main/java/com/cedarsoftware/util/convert/Convert.java @@ -20,5 +20,5 @@ */ @FunctionalInterface public interface Convert { - T convert(Object from, Converter converter, ConverterOptions options); + T convert(Object from, Converter converter); } diff --git a/src/main/java/com/cedarsoftware/util/convert/Converter.java b/src/main/java/com/cedarsoftware/util/convert/Converter.java index 505da6ac..bbde7784 100644 --- a/src/main/java/com/cedarsoftware/util/convert/Converter.java +++ b/src/main/java/com/cedarsoftware/util/convert/Converter.java @@ -79,7 +79,7 @@ public final class Converter { private static final Map, Set> cacheParentTypes = new ConcurrentHashMap<>(); private static final Map, Class> primitiveToWrapper = new HashMap<>(20, .8f); - private static final Map, Class>, Convert> DEFAULT_FACTORY = new ConcurrentHashMap<>(500, .8f); + private static final Map, Class>, Convert> CONVERSION_DB = new ConcurrentHashMap<>(500, .8f); // Create a Map.Entry (pair) of source class to target class. static Map.Entry, Class> pair(Class source, Class target) { @@ -91,6 +91,10 @@ static Map.Entry, Class> pair(Class source, Class target) { buildFactoryConversions(); } + public ConverterOptions getOptions() { + return options; + } + private static void buildPrimitiveWrappers() { primitiveToWrapper.put(int.class, Integer.class); primitiveToWrapper.put(long.class, Long.class); @@ -105,756 +109,756 @@ private static void buildPrimitiveWrappers() { private static void buildFactoryConversions() { // toByte - DEFAULT_FACTORY.put(pair(Void.class, byte.class), NumberConversions::toByteZero); - DEFAULT_FACTORY.put(pair(Void.class, Byte.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, Byte.class), Converter::identity); - DEFAULT_FACTORY.put(pair(Short.class, Byte.class), NumberConversions::toByte); - DEFAULT_FACTORY.put(pair(Integer.class, Byte.class), NumberConversions::toByte); - DEFAULT_FACTORY.put(pair(Long.class, Byte.class), NumberConversions::toByte); - DEFAULT_FACTORY.put(pair(Float.class, Byte.class), NumberConversions::toByte); - DEFAULT_FACTORY.put(pair(Double.class, Byte.class), NumberConversions::toByte); - DEFAULT_FACTORY.put(pair(Boolean.class, Byte.class), BooleanConversions::toByte); - DEFAULT_FACTORY.put(pair(Character.class, Byte.class), CharacterConversions::toByte); - DEFAULT_FACTORY.put(pair(AtomicBoolean.class, Byte.class), AtomicBooleanConversions::toByte); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, Byte.class), NumberConversions::toByte); - DEFAULT_FACTORY.put(pair(AtomicLong.class, Byte.class), NumberConversions::toByte); - DEFAULT_FACTORY.put(pair(BigInteger.class, Byte.class), NumberConversions::toByte); - DEFAULT_FACTORY.put(pair(BigDecimal.class, Byte.class), NumberConversions::toByte); - DEFAULT_FACTORY.put(pair(Number.class, Byte.class), NumberConversions::toByte); - DEFAULT_FACTORY.put(pair(Map.class, Byte.class), MapConversions::toByte); - DEFAULT_FACTORY.put(pair(String.class, Byte.class), StringConversions::toByte); + CONVERSION_DB.put(pair(Void.class, byte.class), NumberConversions::toByteZero); + CONVERSION_DB.put(pair(Void.class, Byte.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, Byte.class), Converter::identity); + CONVERSION_DB.put(pair(Short.class, Byte.class), NumberConversions::toByte); + CONVERSION_DB.put(pair(Integer.class, Byte.class), NumberConversions::toByte); + CONVERSION_DB.put(pair(Long.class, Byte.class), NumberConversions::toByte); + CONVERSION_DB.put(pair(Float.class, Byte.class), NumberConversions::toByte); + CONVERSION_DB.put(pair(Double.class, Byte.class), NumberConversions::toByte); + CONVERSION_DB.put(pair(Boolean.class, Byte.class), BooleanConversions::toByte); + CONVERSION_DB.put(pair(Character.class, Byte.class), CharacterConversions::toByte); + CONVERSION_DB.put(pair(AtomicBoolean.class, Byte.class), AtomicBooleanConversions::toByte); + CONVERSION_DB.put(pair(AtomicInteger.class, Byte.class), NumberConversions::toByte); + CONVERSION_DB.put(pair(AtomicLong.class, Byte.class), NumberConversions::toByte); + CONVERSION_DB.put(pair(BigInteger.class, Byte.class), NumberConversions::toByte); + CONVERSION_DB.put(pair(BigDecimal.class, Byte.class), NumberConversions::toByte); + CONVERSION_DB.put(pair(Number.class, Byte.class), NumberConversions::toByte); + CONVERSION_DB.put(pair(Map.class, Byte.class), MapConversions::toByte); + CONVERSION_DB.put(pair(String.class, Byte.class), StringConversions::toByte); // toShort - DEFAULT_FACTORY.put(pair(Void.class, short.class), NumberConversions::toShortZero); - DEFAULT_FACTORY.put(pair(Void.class, Short.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, Short.class), NumberConversions::toShort); - DEFAULT_FACTORY.put(pair(Short.class, Short.class), Converter::identity); - DEFAULT_FACTORY.put(pair(Integer.class, Short.class), NumberConversions::toShort); - DEFAULT_FACTORY.put(pair(Long.class, Short.class), NumberConversions::toShort); - DEFAULT_FACTORY.put(pair(Float.class, Short.class), NumberConversions::toShort); - DEFAULT_FACTORY.put(pair(Double.class, Short.class), NumberConversions::toShort); - DEFAULT_FACTORY.put(pair(Boolean.class, Short.class), BooleanConversions::toShort); - DEFAULT_FACTORY.put(pair(Character.class, Short.class), CharacterConversions::toShort); - DEFAULT_FACTORY.put(pair(AtomicBoolean.class, Short.class), AtomicBooleanConversions::toShort); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, Short.class), NumberConversions::toShort); - DEFAULT_FACTORY.put(pair(AtomicLong.class, Short.class), NumberConversions::toShort); - DEFAULT_FACTORY.put(pair(BigInteger.class, Short.class), NumberConversions::toShort); - DEFAULT_FACTORY.put(pair(BigDecimal.class, Short.class), NumberConversions::toShort); - DEFAULT_FACTORY.put(pair(Number.class, Short.class), NumberConversions::toShort); - DEFAULT_FACTORY.put(pair(Map.class, Short.class), MapConversions::toShort); - DEFAULT_FACTORY.put(pair(String.class, Short.class), StringConversions::toShort); - DEFAULT_FACTORY.put(pair(Year.class, Short.class), YearConversions::toShort); + CONVERSION_DB.put(pair(Void.class, short.class), NumberConversions::toShortZero); + CONVERSION_DB.put(pair(Void.class, Short.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, Short.class), NumberConversions::toShort); + CONVERSION_DB.put(pair(Short.class, Short.class), Converter::identity); + CONVERSION_DB.put(pair(Integer.class, Short.class), NumberConversions::toShort); + CONVERSION_DB.put(pair(Long.class, Short.class), NumberConversions::toShort); + CONVERSION_DB.put(pair(Float.class, Short.class), NumberConversions::toShort); + CONVERSION_DB.put(pair(Double.class, Short.class), NumberConversions::toShort); + CONVERSION_DB.put(pair(Boolean.class, Short.class), BooleanConversions::toShort); + CONVERSION_DB.put(pair(Character.class, Short.class), CharacterConversions::toShort); + CONVERSION_DB.put(pair(AtomicBoolean.class, Short.class), AtomicBooleanConversions::toShort); + CONVERSION_DB.put(pair(AtomicInteger.class, Short.class), NumberConversions::toShort); + CONVERSION_DB.put(pair(AtomicLong.class, Short.class), NumberConversions::toShort); + CONVERSION_DB.put(pair(BigInteger.class, Short.class), NumberConversions::toShort); + CONVERSION_DB.put(pair(BigDecimal.class, Short.class), NumberConversions::toShort); + CONVERSION_DB.put(pair(Number.class, Short.class), NumberConversions::toShort); + CONVERSION_DB.put(pair(Map.class, Short.class), MapConversions::toShort); + CONVERSION_DB.put(pair(String.class, Short.class), StringConversions::toShort); + CONVERSION_DB.put(pair(Year.class, Short.class), YearConversions::toShort); // toInteger - DEFAULT_FACTORY.put(pair(Void.class, int.class), NumberConversions::toIntZero); - DEFAULT_FACTORY.put(pair(Void.class, Integer.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, Integer.class), NumberConversions::toInt); - DEFAULT_FACTORY.put(pair(Short.class, Integer.class), NumberConversions::toInt); - DEFAULT_FACTORY.put(pair(Integer.class, Integer.class), Converter::identity); - DEFAULT_FACTORY.put(pair(Long.class, Integer.class), NumberConversions::toInt); - DEFAULT_FACTORY.put(pair(Float.class, Integer.class), NumberConversions::toInt); - DEFAULT_FACTORY.put(pair(Double.class, Integer.class), NumberConversions::toInt); - DEFAULT_FACTORY.put(pair(Boolean.class, Integer.class), BooleanConversions::toInteger); - DEFAULT_FACTORY.put(pair(Character.class, Integer.class), CharacterConversions::toInt); - DEFAULT_FACTORY.put(pair(AtomicBoolean.class, Integer.class), AtomicBooleanConversions::toInteger); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, Integer.class), NumberConversions::toInt); - DEFAULT_FACTORY.put(pair(AtomicLong.class, Integer.class), NumberConversions::toInt); - DEFAULT_FACTORY.put(pair(BigInteger.class, Integer.class), NumberConversions::toInt); - DEFAULT_FACTORY.put(pair(BigDecimal.class, Integer.class), NumberConversions::toInt); - DEFAULT_FACTORY.put(pair(Number.class, Integer.class), NumberConversions::toInt); - DEFAULT_FACTORY.put(pair(Map.class, Integer.class), MapConversions::toInt); - DEFAULT_FACTORY.put(pair(String.class, Integer.class), StringConversions::toInt); - DEFAULT_FACTORY.put(pair(Year.class, Integer.class), YearConversions::toInt); + CONVERSION_DB.put(pair(Void.class, int.class), NumberConversions::toIntZero); + CONVERSION_DB.put(pair(Void.class, Integer.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, Integer.class), NumberConversions::toInt); + CONVERSION_DB.put(pair(Short.class, Integer.class), NumberConversions::toInt); + CONVERSION_DB.put(pair(Integer.class, Integer.class), Converter::identity); + CONVERSION_DB.put(pair(Long.class, Integer.class), NumberConversions::toInt); + CONVERSION_DB.put(pair(Float.class, Integer.class), NumberConversions::toInt); + CONVERSION_DB.put(pair(Double.class, Integer.class), NumberConversions::toInt); + CONVERSION_DB.put(pair(Boolean.class, Integer.class), BooleanConversions::toInteger); + CONVERSION_DB.put(pair(Character.class, Integer.class), CharacterConversions::toInt); + CONVERSION_DB.put(pair(AtomicBoolean.class, Integer.class), AtomicBooleanConversions::toInteger); + CONVERSION_DB.put(pair(AtomicInteger.class, Integer.class), NumberConversions::toInt); + CONVERSION_DB.put(pair(AtomicLong.class, Integer.class), NumberConversions::toInt); + CONVERSION_DB.put(pair(BigInteger.class, Integer.class), NumberConversions::toInt); + CONVERSION_DB.put(pair(BigDecimal.class, Integer.class), NumberConversions::toInt); + CONVERSION_DB.put(pair(Number.class, Integer.class), NumberConversions::toInt); + CONVERSION_DB.put(pair(Map.class, Integer.class), MapConversions::toInt); + CONVERSION_DB.put(pair(String.class, Integer.class), StringConversions::toInt); + CONVERSION_DB.put(pair(Year.class, Integer.class), YearConversions::toInt); // toLong - DEFAULT_FACTORY.put(pair(Void.class, long.class), NumberConversions::toLongZero); - DEFAULT_FACTORY.put(pair(Void.class, Long.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, Long.class), NumberConversions::toLong); - DEFAULT_FACTORY.put(pair(Short.class, Long.class), NumberConversions::toLong); - DEFAULT_FACTORY.put(pair(Integer.class, Long.class), NumberConversions::toLong); - DEFAULT_FACTORY.put(pair(Long.class, Long.class), Converter::identity); - DEFAULT_FACTORY.put(pair(Float.class, Long.class), NumberConversions::toLong); - DEFAULT_FACTORY.put(pair(Double.class, Long.class), NumberConversions::toLong); - DEFAULT_FACTORY.put(pair(Boolean.class, Long.class), BooleanConversions::toLong); - DEFAULT_FACTORY.put(pair(Character.class, Long.class), CharacterConversions::toLong); - DEFAULT_FACTORY.put(pair(AtomicBoolean.class, Long.class), AtomicBooleanConversions::toLong); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, Long.class), NumberConversions::toLong); - DEFAULT_FACTORY.put(pair(AtomicLong.class, Long.class), NumberConversions::toLong); - DEFAULT_FACTORY.put(pair(BigInteger.class, Long.class), NumberConversions::toLong); - DEFAULT_FACTORY.put(pair(BigDecimal.class, Long.class), NumberConversions::toLong); - DEFAULT_FACTORY.put(pair(Date.class, Long.class), DateConversions::toLong); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, Long.class), DateConversions::toLong); - DEFAULT_FACTORY.put(pair(Timestamp.class, Long.class), DateConversions::toLong); - DEFAULT_FACTORY.put(pair(Instant.class, Long.class), InstantConversions::toLong); - DEFAULT_FACTORY.put(pair(LocalDate.class, Long.class), LocalDateConversions::toLong); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, Long.class), LocalDateTimeConversions::toLong); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, Long.class), ZonedDateTimeConversions::toLong); - DEFAULT_FACTORY.put(pair(Calendar.class, Long.class), CalendarConversions::toLong); - DEFAULT_FACTORY.put(pair(Number.class, Long.class), NumberConversions::toLong); - DEFAULT_FACTORY.put(pair(Map.class, Long.class), MapConversions::toLong); - DEFAULT_FACTORY.put(pair(String.class, Long.class), StringConversions::toLong); - DEFAULT_FACTORY.put(pair(OffsetDateTime.class, Long.class), OffsetDateTimeConversions::toLong); - DEFAULT_FACTORY.put(pair(Year.class, Long.class), YearConversions::toLong); + CONVERSION_DB.put(pair(Void.class, long.class), NumberConversions::toLongZero); + CONVERSION_DB.put(pair(Void.class, Long.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, Long.class), NumberConversions::toLong); + CONVERSION_DB.put(pair(Short.class, Long.class), NumberConversions::toLong); + CONVERSION_DB.put(pair(Integer.class, Long.class), NumberConversions::toLong); + CONVERSION_DB.put(pair(Long.class, Long.class), Converter::identity); + CONVERSION_DB.put(pair(Float.class, Long.class), NumberConversions::toLong); + CONVERSION_DB.put(pair(Double.class, Long.class), NumberConversions::toLong); + CONVERSION_DB.put(pair(Boolean.class, Long.class), BooleanConversions::toLong); + CONVERSION_DB.put(pair(Character.class, Long.class), CharacterConversions::toLong); + CONVERSION_DB.put(pair(AtomicBoolean.class, Long.class), AtomicBooleanConversions::toLong); + CONVERSION_DB.put(pair(AtomicInteger.class, Long.class), NumberConversions::toLong); + CONVERSION_DB.put(pair(AtomicLong.class, Long.class), NumberConversions::toLong); + CONVERSION_DB.put(pair(BigInteger.class, Long.class), NumberConversions::toLong); + CONVERSION_DB.put(pair(BigDecimal.class, Long.class), NumberConversions::toLong); + CONVERSION_DB.put(pair(Date.class, Long.class), DateConversions::toLong); + CONVERSION_DB.put(pair(java.sql.Date.class, Long.class), DateConversions::toLong); + CONVERSION_DB.put(pair(Timestamp.class, Long.class), DateConversions::toLong); + CONVERSION_DB.put(pair(Instant.class, Long.class), InstantConversions::toLong); + CONVERSION_DB.put(pair(LocalDate.class, Long.class), LocalDateConversions::toLong); + CONVERSION_DB.put(pair(LocalDateTime.class, Long.class), LocalDateTimeConversions::toLong); + CONVERSION_DB.put(pair(ZonedDateTime.class, Long.class), ZonedDateTimeConversions::toLong); + CONVERSION_DB.put(pair(Calendar.class, Long.class), CalendarConversions::toLong); + CONVERSION_DB.put(pair(Number.class, Long.class), NumberConversions::toLong); + CONVERSION_DB.put(pair(Map.class, Long.class), MapConversions::toLong); + CONVERSION_DB.put(pair(String.class, Long.class), StringConversions::toLong); + CONVERSION_DB.put(pair(OffsetDateTime.class, Long.class), OffsetDateTimeConversions::toLong); + CONVERSION_DB.put(pair(Year.class, Long.class), YearConversions::toLong); // toFloat - DEFAULT_FACTORY.put(pair(Void.class, float.class), NumberConversions::toFloatZero); - DEFAULT_FACTORY.put(pair(Void.class, Float.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, Float.class), NumberConversions::toFloat); - DEFAULT_FACTORY.put(pair(Short.class, Float.class), NumberConversions::toFloat); - DEFAULT_FACTORY.put(pair(Integer.class, Float.class), NumberConversions::toFloat); - DEFAULT_FACTORY.put(pair(Long.class, Float.class), NumberConversions::toFloat); - DEFAULT_FACTORY.put(pair(Float.class, Float.class), Converter::identity); - DEFAULT_FACTORY.put(pair(Double.class, Float.class), NumberConversions::toFloat); - DEFAULT_FACTORY.put(pair(Boolean.class, Float.class), BooleanConversions::toFloat); - DEFAULT_FACTORY.put(pair(Character.class, Float.class), CharacterConversions::toFloat); - DEFAULT_FACTORY.put(pair(Instant.class, Float.class), InstantConversions::toFloat); - DEFAULT_FACTORY.put(pair(LocalDate.class, Float.class), LocalDateConversions::toFloat); - DEFAULT_FACTORY.put(pair(AtomicBoolean.class, Float.class), AtomicBooleanConversions::toFloat); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, Float.class), NumberConversions::toFloat); - DEFAULT_FACTORY.put(pair(AtomicLong.class, Float.class), NumberConversions::toFloat); - DEFAULT_FACTORY.put(pair(BigInteger.class, Float.class), NumberConversions::toFloat); - DEFAULT_FACTORY.put(pair(BigDecimal.class, Float.class), NumberConversions::toFloat); - DEFAULT_FACTORY.put(pair(Number.class, Float.class), NumberConversions::toFloat); - DEFAULT_FACTORY.put(pair(Map.class, Float.class), MapConversions::toFloat); - DEFAULT_FACTORY.put(pair(String.class, Float.class), StringConversions::toFloat); - DEFAULT_FACTORY.put(pair(Year.class, Float.class), YearConversions::toFloat); + CONVERSION_DB.put(pair(Void.class, float.class), NumberConversions::toFloatZero); + CONVERSION_DB.put(pair(Void.class, Float.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, Float.class), NumberConversions::toFloat); + CONVERSION_DB.put(pair(Short.class, Float.class), NumberConversions::toFloat); + CONVERSION_DB.put(pair(Integer.class, Float.class), NumberConversions::toFloat); + CONVERSION_DB.put(pair(Long.class, Float.class), NumberConversions::toFloat); + CONVERSION_DB.put(pair(Float.class, Float.class), Converter::identity); + CONVERSION_DB.put(pair(Double.class, Float.class), NumberConversions::toFloat); + CONVERSION_DB.put(pair(Boolean.class, Float.class), BooleanConversions::toFloat); + CONVERSION_DB.put(pair(Character.class, Float.class), CharacterConversions::toFloat); + CONVERSION_DB.put(pair(Instant.class, Float.class), InstantConversions::toFloat); + CONVERSION_DB.put(pair(LocalDate.class, Float.class), LocalDateConversions::toFloat); + CONVERSION_DB.put(pair(AtomicBoolean.class, Float.class), AtomicBooleanConversions::toFloat); + CONVERSION_DB.put(pair(AtomicInteger.class, Float.class), NumberConversions::toFloat); + CONVERSION_DB.put(pair(AtomicLong.class, Float.class), NumberConversions::toFloat); + CONVERSION_DB.put(pair(BigInteger.class, Float.class), NumberConversions::toFloat); + CONVERSION_DB.put(pair(BigDecimal.class, Float.class), NumberConversions::toFloat); + CONVERSION_DB.put(pair(Number.class, Float.class), NumberConversions::toFloat); + CONVERSION_DB.put(pair(Map.class, Float.class), MapConversions::toFloat); + CONVERSION_DB.put(pair(String.class, Float.class), StringConversions::toFloat); + CONVERSION_DB.put(pair(Year.class, Float.class), YearConversions::toFloat); // Double/double conversions supported - DEFAULT_FACTORY.put(pair(Void.class, double.class), NumberConversions::toDoubleZero); - DEFAULT_FACTORY.put(pair(Void.class, Double.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, Double.class), NumberConversions::toDouble); - DEFAULT_FACTORY.put(pair(Short.class, Double.class), NumberConversions::toDouble); - DEFAULT_FACTORY.put(pair(Integer.class, Double.class), NumberConversions::toDouble); - DEFAULT_FACTORY.put(pair(Long.class, Double.class), NumberConversions::toDouble); - DEFAULT_FACTORY.put(pair(Float.class, Double.class), NumberConversions::toDouble); - DEFAULT_FACTORY.put(pair(Double.class, Double.class), Converter::identity); - DEFAULT_FACTORY.put(pair(Boolean.class, Double.class), BooleanConversions::toDouble); - DEFAULT_FACTORY.put(pair(Character.class, Double.class), CharacterConversions::toDouble); - DEFAULT_FACTORY.put(pair(Instant.class, Double.class), InstantConversions::toDouble); - DEFAULT_FACTORY.put(pair(LocalDate.class, Double.class), LocalDateConversions::toDouble); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, Double.class), LocalDateTimeConversions::toLong); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, Double.class), ZonedDateTimeConversions::toLong); - DEFAULT_FACTORY.put(pair(Date.class, Double.class), DateConversions::toLong); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, Double.class), DateConversions::toLong); - DEFAULT_FACTORY.put(pair(Timestamp.class, Double.class), DateConversions::toLong); - DEFAULT_FACTORY.put(pair(AtomicBoolean.class, Double.class), AtomicBooleanConversions::toDouble); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, Double.class), NumberConversions::toDouble); - DEFAULT_FACTORY.put(pair(AtomicLong.class, Double.class), NumberConversions::toDouble); - DEFAULT_FACTORY.put(pair(BigInteger.class, Double.class), NumberConversions::toDouble); - DEFAULT_FACTORY.put(pair(BigDecimal.class, Double.class), NumberConversions::toDouble); - DEFAULT_FACTORY.put(pair(Calendar.class, Double.class), CalendarConversions::toDouble); - DEFAULT_FACTORY.put(pair(Number.class, Double.class), NumberConversions::toDouble); - DEFAULT_FACTORY.put(pair(Map.class, Double.class), MapConversions::toDouble); - DEFAULT_FACTORY.put(pair(String.class, Double.class), StringConversions::toDouble); - DEFAULT_FACTORY.put(pair(Year.class, Double.class), YearConversions::toDouble); + CONVERSION_DB.put(pair(Void.class, double.class), NumberConversions::toDoubleZero); + CONVERSION_DB.put(pair(Void.class, Double.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, Double.class), NumberConversions::toDouble); + CONVERSION_DB.put(pair(Short.class, Double.class), NumberConversions::toDouble); + CONVERSION_DB.put(pair(Integer.class, Double.class), NumberConversions::toDouble); + CONVERSION_DB.put(pair(Long.class, Double.class), NumberConversions::toDouble); + CONVERSION_DB.put(pair(Float.class, Double.class), NumberConversions::toDouble); + CONVERSION_DB.put(pair(Double.class, Double.class), Converter::identity); + CONVERSION_DB.put(pair(Boolean.class, Double.class), BooleanConversions::toDouble); + CONVERSION_DB.put(pair(Character.class, Double.class), CharacterConversions::toDouble); + CONVERSION_DB.put(pair(Instant.class, Double.class), InstantConversions::toDouble); + CONVERSION_DB.put(pair(LocalDate.class, Double.class), LocalDateConversions::toDouble); + CONVERSION_DB.put(pair(LocalDateTime.class, Double.class), LocalDateTimeConversions::toLong); + CONVERSION_DB.put(pair(ZonedDateTime.class, Double.class), ZonedDateTimeConversions::toLong); + CONVERSION_DB.put(pair(Date.class, Double.class), DateConversions::toLong); + CONVERSION_DB.put(pair(java.sql.Date.class, Double.class), DateConversions::toLong); + CONVERSION_DB.put(pair(Timestamp.class, Double.class), DateConversions::toLong); + CONVERSION_DB.put(pair(AtomicBoolean.class, Double.class), AtomicBooleanConversions::toDouble); + CONVERSION_DB.put(pair(AtomicInteger.class, Double.class), NumberConversions::toDouble); + CONVERSION_DB.put(pair(AtomicLong.class, Double.class), NumberConversions::toDouble); + CONVERSION_DB.put(pair(BigInteger.class, Double.class), NumberConversions::toDouble); + CONVERSION_DB.put(pair(BigDecimal.class, Double.class), NumberConversions::toDouble); + CONVERSION_DB.put(pair(Calendar.class, Double.class), CalendarConversions::toDouble); + CONVERSION_DB.put(pair(Number.class, Double.class), NumberConversions::toDouble); + CONVERSION_DB.put(pair(Map.class, Double.class), MapConversions::toDouble); + CONVERSION_DB.put(pair(String.class, Double.class), StringConversions::toDouble); + CONVERSION_DB.put(pair(Year.class, Double.class), YearConversions::toDouble); // Boolean/boolean conversions supported - DEFAULT_FACTORY.put(pair(Void.class, boolean.class), VoidConversions::toBoolean); - DEFAULT_FACTORY.put(pair(Void.class, Boolean.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, Boolean.class), NumberConversions::isIntTypeNotZero); - DEFAULT_FACTORY.put(pair(Short.class, Boolean.class), NumberConversions::isIntTypeNotZero); - DEFAULT_FACTORY.put(pair(Integer.class, Boolean.class), NumberConversions::isIntTypeNotZero); - DEFAULT_FACTORY.put(pair(Long.class, Boolean.class), NumberConversions::isIntTypeNotZero); - DEFAULT_FACTORY.put(pair(Float.class, Boolean.class), NumberConversions::isFloatTypeNotZero); - DEFAULT_FACTORY.put(pair(Double.class, Boolean.class), NumberConversions::isFloatTypeNotZero); - DEFAULT_FACTORY.put(pair(Boolean.class, Boolean.class), Converter::identity); - DEFAULT_FACTORY.put(pair(Character.class, Boolean.class), CharacterConversions::toBoolean); - DEFAULT_FACTORY.put(pair(AtomicBoolean.class, Boolean.class), AtomicBooleanConversions::toBoolean); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, Boolean.class), NumberConversions::isIntTypeNotZero); - DEFAULT_FACTORY.put(pair(AtomicLong.class, Boolean.class), NumberConversions::isIntTypeNotZero); - DEFAULT_FACTORY.put(pair(BigInteger.class, Boolean.class), NumberConversions::isBigIntegerNotZero); - DEFAULT_FACTORY.put(pair(BigDecimal.class, Boolean.class), NumberConversions::isBigDecimalNotZero); - DEFAULT_FACTORY.put(pair(Number.class, Boolean.class), NumberConversions::isIntTypeNotZero); - DEFAULT_FACTORY.put(pair(Map.class, Boolean.class), MapConversions::toBoolean); - DEFAULT_FACTORY.put(pair(String.class, Boolean.class), StringConversions::toBoolean); - DEFAULT_FACTORY.put(pair(Year.class, Boolean.class), YearConversions::toBoolean); + CONVERSION_DB.put(pair(Void.class, boolean.class), VoidConversions::toBoolean); + CONVERSION_DB.put(pair(Void.class, Boolean.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, Boolean.class), NumberConversions::isIntTypeNotZero); + CONVERSION_DB.put(pair(Short.class, Boolean.class), NumberConversions::isIntTypeNotZero); + CONVERSION_DB.put(pair(Integer.class, Boolean.class), NumberConversions::isIntTypeNotZero); + CONVERSION_DB.put(pair(Long.class, Boolean.class), NumberConversions::isIntTypeNotZero); + CONVERSION_DB.put(pair(Float.class, Boolean.class), NumberConversions::isFloatTypeNotZero); + CONVERSION_DB.put(pair(Double.class, Boolean.class), NumberConversions::isFloatTypeNotZero); + CONVERSION_DB.put(pair(Boolean.class, Boolean.class), Converter::identity); + CONVERSION_DB.put(pair(Character.class, Boolean.class), CharacterConversions::toBoolean); + CONVERSION_DB.put(pair(AtomicBoolean.class, Boolean.class), AtomicBooleanConversions::toBoolean); + CONVERSION_DB.put(pair(AtomicInteger.class, Boolean.class), NumberConversions::isIntTypeNotZero); + CONVERSION_DB.put(pair(AtomicLong.class, Boolean.class), NumberConversions::isIntTypeNotZero); + CONVERSION_DB.put(pair(BigInteger.class, Boolean.class), NumberConversions::isBigIntegerNotZero); + CONVERSION_DB.put(pair(BigDecimal.class, Boolean.class), NumberConversions::isBigDecimalNotZero); + CONVERSION_DB.put(pair(Number.class, Boolean.class), NumberConversions::isIntTypeNotZero); + CONVERSION_DB.put(pair(Map.class, Boolean.class), MapConversions::toBoolean); + CONVERSION_DB.put(pair(String.class, Boolean.class), StringConversions::toBoolean); + CONVERSION_DB.put(pair(Year.class, Boolean.class), YearConversions::toBoolean); // Character/char conversions supported - DEFAULT_FACTORY.put(pair(Void.class, char.class), VoidConversions::toChar); - DEFAULT_FACTORY.put(pair(Void.class, Character.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, Character.class), NumberConversions::toCharacter); - DEFAULT_FACTORY.put(pair(Short.class, Character.class), NumberConversions::toCharacter); - DEFAULT_FACTORY.put(pair(Integer.class, Character.class), NumberConversions::toCharacter); - DEFAULT_FACTORY.put(pair(Long.class, Character.class), NumberConversions::toCharacter); - DEFAULT_FACTORY.put(pair(Float.class, Character.class), NumberConversions::toCharacter); - DEFAULT_FACTORY.put(pair(Double.class, Character.class), NumberConversions::toCharacter); - DEFAULT_FACTORY.put(pair(Boolean.class, Character.class), BooleanConversions::toCharacter); - DEFAULT_FACTORY.put(pair(Character.class, Character.class), Converter::identity); - DEFAULT_FACTORY.put(pair(AtomicBoolean.class, Character.class), AtomicBooleanConversions::toCharacter); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, Character.class), NumberConversions::toCharacter); - DEFAULT_FACTORY.put(pair(AtomicLong.class, Character.class), NumberConversions::toCharacter); - DEFAULT_FACTORY.put(pair(BigInteger.class, Character.class), NumberConversions::toCharacter); - DEFAULT_FACTORY.put(pair(BigDecimal.class, Character.class), NumberConversions::toCharacter); - DEFAULT_FACTORY.put(pair(Number.class, Character.class), NumberConversions::toCharacter); - DEFAULT_FACTORY.put(pair(Map.class, Character.class), MapConversions::toCharacter); - DEFAULT_FACTORY.put(pair(String.class, Character.class), StringConversions::toCharacter); + CONVERSION_DB.put(pair(Void.class, char.class), VoidConversions::toChar); + CONVERSION_DB.put(pair(Void.class, Character.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, Character.class), NumberConversions::toCharacter); + CONVERSION_DB.put(pair(Short.class, Character.class), NumberConversions::toCharacter); + CONVERSION_DB.put(pair(Integer.class, Character.class), NumberConversions::toCharacter); + CONVERSION_DB.put(pair(Long.class, Character.class), NumberConversions::toCharacter); + CONVERSION_DB.put(pair(Float.class, Character.class), NumberConversions::toCharacter); + CONVERSION_DB.put(pair(Double.class, Character.class), NumberConversions::toCharacter); + CONVERSION_DB.put(pair(Boolean.class, Character.class), BooleanConversions::toCharacter); + CONVERSION_DB.put(pair(Character.class, Character.class), Converter::identity); + CONVERSION_DB.put(pair(AtomicBoolean.class, Character.class), AtomicBooleanConversions::toCharacter); + CONVERSION_DB.put(pair(AtomicInteger.class, Character.class), NumberConversions::toCharacter); + CONVERSION_DB.put(pair(AtomicLong.class, Character.class), NumberConversions::toCharacter); + CONVERSION_DB.put(pair(BigInteger.class, Character.class), NumberConversions::toCharacter); + CONVERSION_DB.put(pair(BigDecimal.class, Character.class), NumberConversions::toCharacter); + CONVERSION_DB.put(pair(Number.class, Character.class), NumberConversions::toCharacter); + CONVERSION_DB.put(pair(Map.class, Character.class), MapConversions::toCharacter); + CONVERSION_DB.put(pair(String.class, Character.class), StringConversions::toCharacter); // BigInteger versions supported - DEFAULT_FACTORY.put(pair(Void.class, BigInteger.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, BigInteger.class), NumberConversions::integerTypeToBigInteger); - DEFAULT_FACTORY.put(pair(Short.class, BigInteger.class), NumberConversions::integerTypeToBigInteger); - DEFAULT_FACTORY.put(pair(Integer.class, BigInteger.class), NumberConversions::integerTypeToBigInteger); - DEFAULT_FACTORY.put(pair(Long.class, BigInteger.class), NumberConversions::integerTypeToBigInteger); - DEFAULT_FACTORY.put(pair(Float.class, BigInteger.class), NumberConversions::floatingPointToBigInteger); - DEFAULT_FACTORY.put(pair(Double.class, BigInteger.class), NumberConversions::floatingPointToBigInteger); - DEFAULT_FACTORY.put(pair(Boolean.class, BigInteger.class), BooleanConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(Character.class, BigInteger.class), CharacterConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(BigInteger.class, BigInteger.class), Converter::identity); - DEFAULT_FACTORY.put(pair(BigDecimal.class, BigInteger.class), NumberConversions::bigDecimalToBigInteger); - DEFAULT_FACTORY.put(pair(AtomicBoolean.class, BigInteger.class), AtomicBooleanConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, BigInteger.class), NumberConversions::integerTypeToBigInteger); - DEFAULT_FACTORY.put(pair(AtomicLong.class, BigInteger.class), NumberConversions::integerTypeToBigInteger); - DEFAULT_FACTORY.put(pair(Date.class, BigInteger.class), DateConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, BigInteger.class), DateConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(Timestamp.class, BigInteger.class), DateConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(Instant.class, BigInteger.class), InstantConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(LocalDate.class, BigInteger.class), LocalDateConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, BigInteger.class), LocalDateTimeConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, BigInteger.class), ZonedDateTimeConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(UUID.class, BigInteger.class), UUIDConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(Calendar.class, BigInteger.class), CalendarConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(Number.class, BigInteger.class), NumberConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(Map.class, BigInteger.class), MapConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(String.class, BigInteger.class), StringConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(OffsetDateTime.class, BigInteger.class), OffsetDateTimeConversions::toBigInteger); - DEFAULT_FACTORY.put(pair(Year.class, BigInteger.class), YearConversions::toBigInteger); + CONVERSION_DB.put(pair(Void.class, BigInteger.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, BigInteger.class), NumberConversions::integerTypeToBigInteger); + CONVERSION_DB.put(pair(Short.class, BigInteger.class), NumberConversions::integerTypeToBigInteger); + CONVERSION_DB.put(pair(Integer.class, BigInteger.class), NumberConversions::integerTypeToBigInteger); + CONVERSION_DB.put(pair(Long.class, BigInteger.class), NumberConversions::integerTypeToBigInteger); + CONVERSION_DB.put(pair(Float.class, BigInteger.class), NumberConversions::floatingPointToBigInteger); + CONVERSION_DB.put(pair(Double.class, BigInteger.class), NumberConversions::floatingPointToBigInteger); + CONVERSION_DB.put(pair(Boolean.class, BigInteger.class), BooleanConversions::toBigInteger); + CONVERSION_DB.put(pair(Character.class, BigInteger.class), CharacterConversions::toBigInteger); + CONVERSION_DB.put(pair(BigInteger.class, BigInteger.class), Converter::identity); + CONVERSION_DB.put(pair(BigDecimal.class, BigInteger.class), NumberConversions::bigDecimalToBigInteger); + CONVERSION_DB.put(pair(AtomicBoolean.class, BigInteger.class), AtomicBooleanConversions::toBigInteger); + CONVERSION_DB.put(pair(AtomicInteger.class, BigInteger.class), NumberConversions::integerTypeToBigInteger); + CONVERSION_DB.put(pair(AtomicLong.class, BigInteger.class), NumberConversions::integerTypeToBigInteger); + CONVERSION_DB.put(pair(Date.class, BigInteger.class), DateConversions::toBigInteger); + CONVERSION_DB.put(pair(java.sql.Date.class, BigInteger.class), DateConversions::toBigInteger); + CONVERSION_DB.put(pair(Timestamp.class, BigInteger.class), DateConversions::toBigInteger); + CONVERSION_DB.put(pair(Instant.class, BigInteger.class), InstantConversions::toBigInteger); + CONVERSION_DB.put(pair(LocalDate.class, BigInteger.class), LocalDateConversions::toBigInteger); + CONVERSION_DB.put(pair(LocalDateTime.class, BigInteger.class), LocalDateTimeConversions::toBigInteger); + CONVERSION_DB.put(pair(ZonedDateTime.class, BigInteger.class), ZonedDateTimeConversions::toBigInteger); + CONVERSION_DB.put(pair(UUID.class, BigInteger.class), UUIDConversions::toBigInteger); + CONVERSION_DB.put(pair(Calendar.class, BigInteger.class), CalendarConversions::toBigInteger); + CONVERSION_DB.put(pair(Number.class, BigInteger.class), NumberConversions::toBigInteger); + CONVERSION_DB.put(pair(Map.class, BigInteger.class), MapConversions::toBigInteger); + CONVERSION_DB.put(pair(String.class, BigInteger.class), StringConversions::toBigInteger); + CONVERSION_DB.put(pair(OffsetDateTime.class, BigInteger.class), OffsetDateTimeConversions::toBigInteger); + CONVERSION_DB.put(pair(Year.class, BigInteger.class), YearConversions::toBigInteger); // BigDecimal conversions supported - DEFAULT_FACTORY.put(pair(Void.class, BigDecimal.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, BigDecimal.class), NumberConversions::integerTypeToBigDecimal); - DEFAULT_FACTORY.put(pair(Short.class, BigDecimal.class), NumberConversions::integerTypeToBigDecimal); - DEFAULT_FACTORY.put(pair(Integer.class, BigDecimal.class), NumberConversions::integerTypeToBigDecimal); - DEFAULT_FACTORY.put(pair(Long.class, BigDecimal.class), NumberConversions::integerTypeToBigDecimal); - DEFAULT_FACTORY.put(pair(Float.class, BigDecimal.class), NumberConversions::floatingPointToBigDecimal); - DEFAULT_FACTORY.put(pair(Double.class, BigDecimal.class), NumberConversions::floatingPointToBigDecimal); - DEFAULT_FACTORY.put(pair(Boolean.class, BigDecimal.class), BooleanConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(Character.class, BigDecimal.class), CharacterConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(BigDecimal.class, BigDecimal.class), Converter::identity); - DEFAULT_FACTORY.put(pair(BigInteger.class, BigDecimal.class), NumberConversions::bigIntegerToBigDecimal); - DEFAULT_FACTORY.put(pair(AtomicBoolean.class, BigDecimal.class), AtomicBooleanConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, BigDecimal.class), NumberConversions::integerTypeToBigDecimal); - DEFAULT_FACTORY.put(pair(AtomicLong.class, BigDecimal.class), NumberConversions::integerTypeToBigDecimal); - DEFAULT_FACTORY.put(pair(Date.class, BigDecimal.class), DateConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, BigDecimal.class), DateConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(Timestamp.class, BigDecimal.class), DateConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(Instant.class, BigDecimal.class), InstantConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(LocalDate.class, BigDecimal.class), LocalDateConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, BigDecimal.class), LocalDateTimeConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, BigDecimal.class), ZonedDateTimeConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(UUID.class, BigDecimal.class), UUIDConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(Calendar.class, BigDecimal.class), CalendarConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(Number.class, BigDecimal.class), NumberConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(Map.class, BigDecimal.class), MapConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(String.class, BigDecimal.class), StringConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(OffsetDateTime.class, BigDecimal.class), OffsetDateTimeConversions::toBigDecimal); - DEFAULT_FACTORY.put(pair(Year.class, BigDecimal.class), YearConversions::toBigDecimal); + CONVERSION_DB.put(pair(Void.class, BigDecimal.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, BigDecimal.class), NumberConversions::integerTypeToBigDecimal); + CONVERSION_DB.put(pair(Short.class, BigDecimal.class), NumberConversions::integerTypeToBigDecimal); + CONVERSION_DB.put(pair(Integer.class, BigDecimal.class), NumberConversions::integerTypeToBigDecimal); + CONVERSION_DB.put(pair(Long.class, BigDecimal.class), NumberConversions::integerTypeToBigDecimal); + CONVERSION_DB.put(pair(Float.class, BigDecimal.class), NumberConversions::floatingPointToBigDecimal); + CONVERSION_DB.put(pair(Double.class, BigDecimal.class), NumberConversions::floatingPointToBigDecimal); + CONVERSION_DB.put(pair(Boolean.class, BigDecimal.class), BooleanConversions::toBigDecimal); + CONVERSION_DB.put(pair(Character.class, BigDecimal.class), CharacterConversions::toBigDecimal); + CONVERSION_DB.put(pair(BigDecimal.class, BigDecimal.class), Converter::identity); + CONVERSION_DB.put(pair(BigInteger.class, BigDecimal.class), NumberConversions::bigIntegerToBigDecimal); + CONVERSION_DB.put(pair(AtomicBoolean.class, BigDecimal.class), AtomicBooleanConversions::toBigDecimal); + CONVERSION_DB.put(pair(AtomicInteger.class, BigDecimal.class), NumberConversions::integerTypeToBigDecimal); + CONVERSION_DB.put(pair(AtomicLong.class, BigDecimal.class), NumberConversions::integerTypeToBigDecimal); + CONVERSION_DB.put(pair(Date.class, BigDecimal.class), DateConversions::toBigDecimal); + CONVERSION_DB.put(pair(java.sql.Date.class, BigDecimal.class), DateConversions::toBigDecimal); + CONVERSION_DB.put(pair(Timestamp.class, BigDecimal.class), DateConversions::toBigDecimal); + CONVERSION_DB.put(pair(Instant.class, BigDecimal.class), InstantConversions::toBigDecimal); + CONVERSION_DB.put(pair(LocalDate.class, BigDecimal.class), LocalDateConversions::toBigDecimal); + CONVERSION_DB.put(pair(LocalDateTime.class, BigDecimal.class), LocalDateTimeConversions::toBigDecimal); + CONVERSION_DB.put(pair(ZonedDateTime.class, BigDecimal.class), ZonedDateTimeConversions::toBigDecimal); + CONVERSION_DB.put(pair(UUID.class, BigDecimal.class), UUIDConversions::toBigDecimal); + CONVERSION_DB.put(pair(Calendar.class, BigDecimal.class), CalendarConversions::toBigDecimal); + CONVERSION_DB.put(pair(Number.class, BigDecimal.class), NumberConversions::toBigDecimal); + CONVERSION_DB.put(pair(Map.class, BigDecimal.class), MapConversions::toBigDecimal); + CONVERSION_DB.put(pair(String.class, BigDecimal.class), StringConversions::toBigDecimal); + CONVERSION_DB.put(pair(OffsetDateTime.class, BigDecimal.class), OffsetDateTimeConversions::toBigDecimal); + CONVERSION_DB.put(pair(Year.class, BigDecimal.class), YearConversions::toBigDecimal); // AtomicBoolean conversions supported - DEFAULT_FACTORY.put(pair(Void.class, AtomicBoolean.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(Short.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(Integer.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(Long.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(Float.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(Double.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(Boolean.class, AtomicBoolean.class), BooleanConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(Character.class, AtomicBoolean.class), CharacterConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(BigInteger.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(BigDecimal.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(AtomicBoolean.class, AtomicBoolean.class), AtomicBooleanConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(AtomicLong.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(Number.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(Map.class, AtomicBoolean.class), MapConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(String.class, AtomicBoolean.class), StringConversions::toAtomicBoolean); - DEFAULT_FACTORY.put(pair(Year.class, AtomicBoolean.class), YearConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(Void.class, AtomicBoolean.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(Short.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(Integer.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(Long.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(Float.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(Double.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(Boolean.class, AtomicBoolean.class), BooleanConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(Character.class, AtomicBoolean.class), CharacterConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(BigInteger.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(BigDecimal.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(AtomicBoolean.class, AtomicBoolean.class), AtomicBooleanConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(AtomicInteger.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(AtomicLong.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(Number.class, AtomicBoolean.class), NumberConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(Map.class, AtomicBoolean.class), MapConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(String.class, AtomicBoolean.class), StringConversions::toAtomicBoolean); + CONVERSION_DB.put(pair(Year.class, AtomicBoolean.class), YearConversions::toAtomicBoolean); // AtomicInteger conversions supported - DEFAULT_FACTORY.put(pair(Void.class, AtomicInteger.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, AtomicInteger.class), NumberConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(Short.class, AtomicInteger.class), NumberConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(Integer.class, AtomicInteger.class), NumberConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(Long.class, AtomicInteger.class), NumberConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(Float.class, AtomicInteger.class), NumberConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(Double.class, AtomicInteger.class), NumberConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(Boolean.class, AtomicInteger.class), BooleanConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(Character.class, AtomicInteger.class), CharacterConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(BigInteger.class, AtomicInteger.class), NumberConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(BigDecimal.class, AtomicInteger.class), NumberConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, AtomicInteger.class), NumberConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(AtomicBoolean.class, AtomicInteger.class), AtomicBooleanConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(AtomicLong.class, AtomicInteger.class), NumberConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(LocalDate.class, AtomicInteger.class), LocalDateConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(Number.class, AtomicBoolean.class), NumberConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(Map.class, AtomicInteger.class), MapConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(String.class, AtomicInteger.class), StringConversions::toAtomicInteger); - DEFAULT_FACTORY.put(pair(Year.class, AtomicInteger.class), YearConversions::toAtomicInteger); + CONVERSION_DB.put(pair(Void.class, AtomicInteger.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, AtomicInteger.class), NumberConversions::toAtomicInteger); + CONVERSION_DB.put(pair(Short.class, AtomicInteger.class), NumberConversions::toAtomicInteger); + CONVERSION_DB.put(pair(Integer.class, AtomicInteger.class), NumberConversions::toAtomicInteger); + CONVERSION_DB.put(pair(Long.class, AtomicInteger.class), NumberConversions::toAtomicInteger); + CONVERSION_DB.put(pair(Float.class, AtomicInteger.class), NumberConversions::toAtomicInteger); + CONVERSION_DB.put(pair(Double.class, AtomicInteger.class), NumberConversions::toAtomicInteger); + CONVERSION_DB.put(pair(Boolean.class, AtomicInteger.class), BooleanConversions::toAtomicInteger); + CONVERSION_DB.put(pair(Character.class, AtomicInteger.class), CharacterConversions::toAtomicInteger); + CONVERSION_DB.put(pair(BigInteger.class, AtomicInteger.class), NumberConversions::toAtomicInteger); + CONVERSION_DB.put(pair(BigDecimal.class, AtomicInteger.class), NumberConversions::toAtomicInteger); + CONVERSION_DB.put(pair(AtomicInteger.class, AtomicInteger.class), NumberConversions::toAtomicInteger); + CONVERSION_DB.put(pair(AtomicBoolean.class, AtomicInteger.class), AtomicBooleanConversions::toAtomicInteger); + CONVERSION_DB.put(pair(AtomicLong.class, AtomicInteger.class), NumberConversions::toAtomicInteger); + CONVERSION_DB.put(pair(LocalDate.class, AtomicInteger.class), LocalDateConversions::toAtomicLong); + CONVERSION_DB.put(pair(Number.class, AtomicBoolean.class), NumberConversions::toAtomicInteger); + CONVERSION_DB.put(pair(Map.class, AtomicInteger.class), MapConversions::toAtomicInteger); + CONVERSION_DB.put(pair(String.class, AtomicInteger.class), StringConversions::toAtomicInteger); + CONVERSION_DB.put(pair(Year.class, AtomicInteger.class), YearConversions::toAtomicInteger); // AtomicLong conversions supported - DEFAULT_FACTORY.put(pair(Void.class, AtomicLong.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, AtomicLong.class), NumberConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(Short.class, AtomicLong.class), NumberConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(Integer.class, AtomicLong.class), NumberConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(Long.class, AtomicLong.class), NumberConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(Float.class, AtomicLong.class), NumberConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(Double.class, AtomicLong.class), NumberConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(Boolean.class, AtomicLong.class), BooleanConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(Character.class, AtomicLong.class), CharacterConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(BigInteger.class, AtomicLong.class), NumberConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(BigDecimal.class, AtomicLong.class), NumberConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(AtomicBoolean.class, AtomicLong.class), AtomicBooleanConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(AtomicLong.class, AtomicLong.class), Converter::identity); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, AtomicLong.class), NumberConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(Date.class, AtomicLong.class), DateConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, AtomicLong.class), DateConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(Timestamp.class, AtomicLong.class), DateConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(Instant.class, AtomicLong.class), InstantConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(LocalDate.class, AtomicLong.class), LocalDateConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, AtomicLong.class), LocalDateTimeConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, AtomicLong.class), ZonedDateTimeConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(Calendar.class, AtomicLong.class), CalendarConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(Number.class, AtomicLong.class), NumberConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(Map.class, AtomicLong.class), MapConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(String.class, AtomicLong.class), StringConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(OffsetDateTime.class, AtomicLong.class), OffsetDateTimeConversions::toAtomicLong); - DEFAULT_FACTORY.put(pair(Year.class, AtomicLong.class), YearConversions::toAtomicLong); + CONVERSION_DB.put(pair(Void.class, AtomicLong.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, AtomicLong.class), NumberConversions::toAtomicLong); + CONVERSION_DB.put(pair(Short.class, AtomicLong.class), NumberConversions::toAtomicLong); + CONVERSION_DB.put(pair(Integer.class, AtomicLong.class), NumberConversions::toAtomicLong); + CONVERSION_DB.put(pair(Long.class, AtomicLong.class), NumberConversions::toAtomicLong); + CONVERSION_DB.put(pair(Float.class, AtomicLong.class), NumberConversions::toAtomicLong); + CONVERSION_DB.put(pair(Double.class, AtomicLong.class), NumberConversions::toAtomicLong); + CONVERSION_DB.put(pair(Boolean.class, AtomicLong.class), BooleanConversions::toAtomicLong); + CONVERSION_DB.put(pair(Character.class, AtomicLong.class), CharacterConversions::toAtomicLong); + CONVERSION_DB.put(pair(BigInteger.class, AtomicLong.class), NumberConversions::toAtomicLong); + CONVERSION_DB.put(pair(BigDecimal.class, AtomicLong.class), NumberConversions::toAtomicLong); + CONVERSION_DB.put(pair(AtomicBoolean.class, AtomicLong.class), AtomicBooleanConversions::toAtomicLong); + CONVERSION_DB.put(pair(AtomicLong.class, AtomicLong.class), Converter::identity); + CONVERSION_DB.put(pair(AtomicInteger.class, AtomicLong.class), NumberConversions::toAtomicLong); + CONVERSION_DB.put(pair(Date.class, AtomicLong.class), DateConversions::toAtomicLong); + CONVERSION_DB.put(pair(java.sql.Date.class, AtomicLong.class), DateConversions::toAtomicLong); + CONVERSION_DB.put(pair(Timestamp.class, AtomicLong.class), DateConversions::toAtomicLong); + CONVERSION_DB.put(pair(Instant.class, AtomicLong.class), InstantConversions::toAtomicLong); + CONVERSION_DB.put(pair(LocalDate.class, AtomicLong.class), LocalDateConversions::toAtomicLong); + CONVERSION_DB.put(pair(LocalDateTime.class, AtomicLong.class), LocalDateTimeConversions::toAtomicLong); + CONVERSION_DB.put(pair(ZonedDateTime.class, AtomicLong.class), ZonedDateTimeConversions::toAtomicLong); + CONVERSION_DB.put(pair(Calendar.class, AtomicLong.class), CalendarConversions::toAtomicLong); + CONVERSION_DB.put(pair(Number.class, AtomicLong.class), NumberConversions::toAtomicLong); + CONVERSION_DB.put(pair(Map.class, AtomicLong.class), MapConversions::toAtomicLong); + CONVERSION_DB.put(pair(String.class, AtomicLong.class), StringConversions::toAtomicLong); + CONVERSION_DB.put(pair(OffsetDateTime.class, AtomicLong.class), OffsetDateTimeConversions::toAtomicLong); + CONVERSION_DB.put(pair(Year.class, AtomicLong.class), YearConversions::toAtomicLong); // Date conversions supported - DEFAULT_FACTORY.put(pair(Void.class, Date.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, Date.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Short.class, Date.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Integer.class, Date.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Long.class, Date.class), NumberConversions::toDate); - DEFAULT_FACTORY.put(pair(Double.class, Date.class), NumberConversions::toDate); - DEFAULT_FACTORY.put(pair(BigInteger.class, Date.class), NumberConversions::toDate); - DEFAULT_FACTORY.put(pair(BigDecimal.class, Date.class), NumberConversions::toDate); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, Date.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(AtomicLong.class, Date.class), NumberConversions::toDate); - DEFAULT_FACTORY.put(pair(Date.class, Date.class), DateConversions::toDate); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, Date.class), DateConversions::toDate); - DEFAULT_FACTORY.put(pair(Timestamp.class, Date.class), DateConversions::toDate); - DEFAULT_FACTORY.put(pair(Instant.class, Date.class), InstantConversions::toDate); - DEFAULT_FACTORY.put(pair(LocalDate.class, Date.class), LocalDateConversions::toDate); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, Date.class), LocalDateTimeConversions::toDate); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, Date.class), ZonedDateTimeConversions::toDate); - DEFAULT_FACTORY.put(pair(Calendar.class, Date.class), CalendarConversions::toDate); - DEFAULT_FACTORY.put(pair(Number.class, Date.class), NumberConversions::toDate); - DEFAULT_FACTORY.put(pair(Map.class, Date.class), MapConversions::toDate); - DEFAULT_FACTORY.put(pair(String.class, Date.class), StringConversions::toDate); - DEFAULT_FACTORY.put(pair(OffsetDateTime.class, Date.class), OffsetDateTimeConversions::toDate); + CONVERSION_DB.put(pair(Void.class, Date.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, Date.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Short.class, Date.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Integer.class, Date.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Long.class, Date.class), NumberConversions::toDate); + CONVERSION_DB.put(pair(Double.class, Date.class), NumberConversions::toDate); + CONVERSION_DB.put(pair(BigInteger.class, Date.class), NumberConversions::toDate); + CONVERSION_DB.put(pair(BigDecimal.class, Date.class), NumberConversions::toDate); + CONVERSION_DB.put(pair(AtomicInteger.class, Date.class), UNSUPPORTED); + CONVERSION_DB.put(pair(AtomicLong.class, Date.class), NumberConversions::toDate); + CONVERSION_DB.put(pair(Date.class, Date.class), DateConversions::toDate); + CONVERSION_DB.put(pair(java.sql.Date.class, Date.class), DateConversions::toDate); + CONVERSION_DB.put(pair(Timestamp.class, Date.class), DateConversions::toDate); + CONVERSION_DB.put(pair(Instant.class, Date.class), InstantConversions::toDate); + CONVERSION_DB.put(pair(LocalDate.class, Date.class), LocalDateConversions::toDate); + CONVERSION_DB.put(pair(LocalDateTime.class, Date.class), LocalDateTimeConversions::toDate); + CONVERSION_DB.put(pair(ZonedDateTime.class, Date.class), ZonedDateTimeConversions::toDate); + CONVERSION_DB.put(pair(Calendar.class, Date.class), CalendarConversions::toDate); + CONVERSION_DB.put(pair(Number.class, Date.class), NumberConversions::toDate); + CONVERSION_DB.put(pair(Map.class, Date.class), MapConversions::toDate); + CONVERSION_DB.put(pair(String.class, Date.class), StringConversions::toDate); + CONVERSION_DB.put(pair(OffsetDateTime.class, Date.class), OffsetDateTimeConversions::toDate); // java.sql.Date conversion supported - DEFAULT_FACTORY.put(pair(Void.class, java.sql.Date.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, java.sql.Date.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Short.class, java.sql.Date.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Integer.class, java.sql.Date.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Long.class, java.sql.Date.class), NumberConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(Double.class, java.sql.Date.class), NumberConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(BigInteger.class, java.sql.Date.class), NumberConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(BigDecimal.class, java.sql.Date.class), NumberConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, java.sql.Date.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(AtomicLong.class, java.sql.Date.class), NumberConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, java.sql.Date.class), DateConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(Date.class, java.sql.Date.class), DateConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(Timestamp.class, java.sql.Date.class), DateConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(Instant.class, java.sql.Date.class), InstantConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(LocalDate.class, java.sql.Date.class), LocalDateConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, java.sql.Date.class), LocalDateTimeConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, java.sql.Date.class), ZonedDateTimeConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(Calendar.class, java.sql.Date.class), CalendarConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(Number.class, java.sql.Date.class), NumberConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(Map.class, java.sql.Date.class), MapConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(String.class, java.sql.Date.class), StringConversions::toSqlDate); - DEFAULT_FACTORY.put(pair(OffsetDateTime.class, java.sql.Date.class), OffsetDateTimeConversions::toSqlDate); + CONVERSION_DB.put(pair(Void.class, java.sql.Date.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, java.sql.Date.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Short.class, java.sql.Date.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Integer.class, java.sql.Date.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Long.class, java.sql.Date.class), NumberConversions::toSqlDate); + CONVERSION_DB.put(pair(Double.class, java.sql.Date.class), NumberConversions::toSqlDate); + CONVERSION_DB.put(pair(BigInteger.class, java.sql.Date.class), NumberConversions::toSqlDate); + CONVERSION_DB.put(pair(BigDecimal.class, java.sql.Date.class), NumberConversions::toSqlDate); + CONVERSION_DB.put(pair(AtomicInteger.class, java.sql.Date.class), UNSUPPORTED); + CONVERSION_DB.put(pair(AtomicLong.class, java.sql.Date.class), NumberConversions::toSqlDate); + CONVERSION_DB.put(pair(java.sql.Date.class, java.sql.Date.class), DateConversions::toSqlDate); + CONVERSION_DB.put(pair(Date.class, java.sql.Date.class), DateConversions::toSqlDate); + CONVERSION_DB.put(pair(Timestamp.class, java.sql.Date.class), DateConversions::toSqlDate); + CONVERSION_DB.put(pair(Instant.class, java.sql.Date.class), InstantConversions::toSqlDate); + CONVERSION_DB.put(pair(LocalDate.class, java.sql.Date.class), LocalDateConversions::toSqlDate); + CONVERSION_DB.put(pair(LocalDateTime.class, java.sql.Date.class), LocalDateTimeConversions::toSqlDate); + CONVERSION_DB.put(pair(ZonedDateTime.class, java.sql.Date.class), ZonedDateTimeConversions::toSqlDate); + CONVERSION_DB.put(pair(Calendar.class, java.sql.Date.class), CalendarConversions::toSqlDate); + CONVERSION_DB.put(pair(Number.class, java.sql.Date.class), NumberConversions::toSqlDate); + CONVERSION_DB.put(pair(Map.class, java.sql.Date.class), MapConversions::toSqlDate); + CONVERSION_DB.put(pair(String.class, java.sql.Date.class), StringConversions::toSqlDate); + CONVERSION_DB.put(pair(OffsetDateTime.class, java.sql.Date.class), OffsetDateTimeConversions::toSqlDate); // Timestamp conversions supported - DEFAULT_FACTORY.put(pair(Void.class, Timestamp.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, Timestamp.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Short.class, Timestamp.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Integer.class, Timestamp.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Long.class, Timestamp.class), NumberConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(Double.class, Timestamp.class), NumberConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(BigInteger.class, Timestamp.class), NumberConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(BigDecimal.class, Timestamp.class), NumberConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, Timestamp.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(AtomicLong.class, Timestamp.class), NumberConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(Timestamp.class, Timestamp.class), DateConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, Timestamp.class), DateConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(Date.class, Timestamp.class), DateConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(Instant.class,Timestamp.class), InstantConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(LocalDate.class, Timestamp.class), LocalDateConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, Timestamp.class), LocalDateTimeConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, Timestamp.class), ZonedDateTimeConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(Calendar.class, Timestamp.class), CalendarConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(Number.class, Timestamp.class), NumberConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(Map.class, Timestamp.class), MapConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(String.class, Timestamp.class), StringConversions::toTimestamp); - DEFAULT_FACTORY.put(pair(OffsetDateTime.class, Timestamp.class), OffsetDateTimeConversions::toTimestamp); + CONVERSION_DB.put(pair(Void.class, Timestamp.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, Timestamp.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Short.class, Timestamp.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Integer.class, Timestamp.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Long.class, Timestamp.class), NumberConversions::toTimestamp); + CONVERSION_DB.put(pair(Double.class, Timestamp.class), NumberConversions::toTimestamp); + CONVERSION_DB.put(pair(BigInteger.class, Timestamp.class), NumberConversions::toTimestamp); + CONVERSION_DB.put(pair(BigDecimal.class, Timestamp.class), NumberConversions::toTimestamp); + CONVERSION_DB.put(pair(AtomicInteger.class, Timestamp.class), UNSUPPORTED); + CONVERSION_DB.put(pair(AtomicLong.class, Timestamp.class), NumberConversions::toTimestamp); + CONVERSION_DB.put(pair(Timestamp.class, Timestamp.class), DateConversions::toTimestamp); + CONVERSION_DB.put(pair(java.sql.Date.class, Timestamp.class), DateConversions::toTimestamp); + CONVERSION_DB.put(pair(Date.class, Timestamp.class), DateConversions::toTimestamp); + CONVERSION_DB.put(pair(Instant.class,Timestamp.class), InstantConversions::toTimestamp); + CONVERSION_DB.put(pair(LocalDate.class, Timestamp.class), LocalDateConversions::toTimestamp); + CONVERSION_DB.put(pair(LocalDateTime.class, Timestamp.class), LocalDateTimeConversions::toTimestamp); + CONVERSION_DB.put(pair(ZonedDateTime.class, Timestamp.class), ZonedDateTimeConversions::toTimestamp); + CONVERSION_DB.put(pair(Calendar.class, Timestamp.class), CalendarConversions::toTimestamp); + CONVERSION_DB.put(pair(Number.class, Timestamp.class), NumberConversions::toTimestamp); + CONVERSION_DB.put(pair(Map.class, Timestamp.class), MapConversions::toTimestamp); + CONVERSION_DB.put(pair(String.class, Timestamp.class), StringConversions::toTimestamp); + CONVERSION_DB.put(pair(OffsetDateTime.class, Timestamp.class), OffsetDateTimeConversions::toTimestamp); // Calendar conversions supported - DEFAULT_FACTORY.put(pair(Void.class, Calendar.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, Calendar.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Short.class, Calendar.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Integer.class, Calendar.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Long.class, Calendar.class), NumberConversions::toCalendar); - DEFAULT_FACTORY.put(pair(Double.class, Calendar.class), NumberConversions::toCalendar); - DEFAULT_FACTORY.put(pair(BigInteger.class, Calendar.class), NumberConversions::toCalendar); - DEFAULT_FACTORY.put(pair(BigDecimal.class, Calendar.class), NumberConversions::toCalendar); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, Calendar.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(AtomicLong.class, Calendar.class), NumberConversions::toCalendar); - DEFAULT_FACTORY.put(pair(Date.class, Calendar.class), DateConversions::toCalendar); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, Calendar.class), DateConversions::toCalendar); - DEFAULT_FACTORY.put(pair(Timestamp.class, Calendar.class), DateConversions::toCalendar); - DEFAULT_FACTORY.put(pair(Instant.class, Calendar.class), InstantConversions::toCalendar); - DEFAULT_FACTORY.put(pair(LocalDate.class, Calendar.class), LocalDateConversions::toCalendar); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, Calendar.class), LocalDateTimeConversions::toCalendar); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, Calendar.class), ZonedDateTimeConversions::toCalendar); - DEFAULT_FACTORY.put(pair(Calendar.class, Calendar.class), CalendarConversions::clone); - DEFAULT_FACTORY.put(pair(Number.class, Calendar.class), NumberConversions::toCalendar); - DEFAULT_FACTORY.put(pair(Map.class, Calendar.class), MapConversions::toCalendar); - DEFAULT_FACTORY.put(pair(String.class, Calendar.class), StringConversions::toCalendar); - DEFAULT_FACTORY.put(pair(OffsetDateTime.class, Calendar.class), OffsetDateTimeConversions::toCalendar); + CONVERSION_DB.put(pair(Void.class, Calendar.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, Calendar.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Short.class, Calendar.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Integer.class, Calendar.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Long.class, Calendar.class), NumberConversions::toCalendar); + CONVERSION_DB.put(pair(Double.class, Calendar.class), NumberConversions::toCalendar); + CONVERSION_DB.put(pair(BigInteger.class, Calendar.class), NumberConversions::toCalendar); + CONVERSION_DB.put(pair(BigDecimal.class, Calendar.class), NumberConversions::toCalendar); + CONVERSION_DB.put(pair(AtomicInteger.class, Calendar.class), UNSUPPORTED); + CONVERSION_DB.put(pair(AtomicLong.class, Calendar.class), NumberConversions::toCalendar); + CONVERSION_DB.put(pair(Date.class, Calendar.class), DateConversions::toCalendar); + CONVERSION_DB.put(pair(java.sql.Date.class, Calendar.class), DateConversions::toCalendar); + CONVERSION_DB.put(pair(Timestamp.class, Calendar.class), DateConversions::toCalendar); + CONVERSION_DB.put(pair(Instant.class, Calendar.class), InstantConversions::toCalendar); + CONVERSION_DB.put(pair(LocalDate.class, Calendar.class), LocalDateConversions::toCalendar); + CONVERSION_DB.put(pair(LocalDateTime.class, Calendar.class), LocalDateTimeConversions::toCalendar); + CONVERSION_DB.put(pair(ZonedDateTime.class, Calendar.class), ZonedDateTimeConversions::toCalendar); + CONVERSION_DB.put(pair(Calendar.class, Calendar.class), CalendarConversions::clone); + CONVERSION_DB.put(pair(Number.class, Calendar.class), NumberConversions::toCalendar); + CONVERSION_DB.put(pair(Map.class, Calendar.class), MapConversions::toCalendar); + CONVERSION_DB.put(pair(String.class, Calendar.class), StringConversions::toCalendar); + CONVERSION_DB.put(pair(OffsetDateTime.class, Calendar.class), OffsetDateTimeConversions::toCalendar); // LocalDate conversions supported - DEFAULT_FACTORY.put(pair(Void.class, LocalDate.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, LocalDate.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Short.class, LocalDate.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Integer.class, LocalDate.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Long.class, LocalDate.class), NumberConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(Double.class, LocalDate.class), NumberConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(BigInteger.class, LocalDate.class), NumberConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(BigDecimal.class, LocalDate.class), NumberConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, LocalDate.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(AtomicLong.class, LocalDate.class), NumberConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, LocalDate.class), DateConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(Timestamp.class, LocalDate.class), DateConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(Date.class, LocalDate.class), DateConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(Instant.class, LocalDate.class), InstantConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(LocalDate.class, LocalDate.class), LocalDateConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, LocalDate.class), LocalDateTimeConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, LocalDate.class), ZonedDateTimeConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(Calendar.class, LocalDate.class), CalendarConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(Number.class, LocalDate.class), NumberConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(Map.class, LocalDate.class), MapConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(String.class, LocalDate.class), StringConversions::toLocalDate); - DEFAULT_FACTORY.put(pair(OffsetDateTime.class, LocalDate.class), OffsetDateTimeConversions::toLocalDate); + CONVERSION_DB.put(pair(Void.class, LocalDate.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, LocalDate.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Short.class, LocalDate.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Integer.class, LocalDate.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Long.class, LocalDate.class), NumberConversions::toLocalDate); + CONVERSION_DB.put(pair(Double.class, LocalDate.class), NumberConversions::toLocalDate); + CONVERSION_DB.put(pair(BigInteger.class, LocalDate.class), NumberConversions::toLocalDate); + CONVERSION_DB.put(pair(BigDecimal.class, LocalDate.class), NumberConversions::toLocalDate); + CONVERSION_DB.put(pair(AtomicInteger.class, LocalDate.class), UNSUPPORTED); + CONVERSION_DB.put(pair(AtomicLong.class, LocalDate.class), NumberConversions::toLocalDate); + CONVERSION_DB.put(pair(java.sql.Date.class, LocalDate.class), DateConversions::toLocalDate); + CONVERSION_DB.put(pair(Timestamp.class, LocalDate.class), DateConversions::toLocalDate); + CONVERSION_DB.put(pair(Date.class, LocalDate.class), DateConversions::toLocalDate); + CONVERSION_DB.put(pair(Instant.class, LocalDate.class), InstantConversions::toLocalDate); + CONVERSION_DB.put(pair(LocalDate.class, LocalDate.class), LocalDateConversions::toLocalDate); + CONVERSION_DB.put(pair(LocalDateTime.class, LocalDate.class), LocalDateTimeConversions::toLocalDate); + CONVERSION_DB.put(pair(ZonedDateTime.class, LocalDate.class), ZonedDateTimeConversions::toLocalDate); + CONVERSION_DB.put(pair(Calendar.class, LocalDate.class), CalendarConversions::toLocalDate); + CONVERSION_DB.put(pair(Number.class, LocalDate.class), NumberConversions::toLocalDate); + CONVERSION_DB.put(pair(Map.class, LocalDate.class), MapConversions::toLocalDate); + CONVERSION_DB.put(pair(String.class, LocalDate.class), StringConversions::toLocalDate); + CONVERSION_DB.put(pair(OffsetDateTime.class, LocalDate.class), OffsetDateTimeConversions::toLocalDate); // LocalDateTime conversions supported - DEFAULT_FACTORY.put(pair(Void.class, LocalDateTime.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, LocalDateTime.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Short.class, LocalDateTime.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Integer.class, LocalDateTime.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Long.class, LocalDateTime.class), NumberConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(Double.class, LocalDateTime.class), NumberConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(BigInteger.class, LocalDateTime.class), NumberConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(BigDecimal.class, LocalDateTime.class), NumberConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, LocalDateTime.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(AtomicLong.class, LocalDateTime.class), NumberConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, LocalDateTime.class), DateConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(Timestamp.class, LocalDateTime.class), DateConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(Date.class, LocalDateTime.class), DateConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(Instant.class, LocalDateTime.class), InstantConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, LocalDateTime.class), LocalDateTimeConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(LocalDate.class, LocalDateTime.class), LocalDateConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, LocalDateTime.class), ZonedDateTimeConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(Calendar.class, LocalDateTime.class), CalendarConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(Number.class, LocalDateTime.class), NumberConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(Map.class, LocalDateTime.class), MapConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(String.class, LocalDateTime.class), StringConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(OffsetDateTime.class, LocalDateTime.class), OffsetDateTimeConversions::toLocalDateTime); + CONVERSION_DB.put(pair(Void.class, LocalDateTime.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, LocalDateTime.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Short.class, LocalDateTime.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Integer.class, LocalDateTime.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Long.class, LocalDateTime.class), NumberConversions::toLocalDateTime); + CONVERSION_DB.put(pair(Double.class, LocalDateTime.class), NumberConversions::toLocalDateTime); + CONVERSION_DB.put(pair(BigInteger.class, LocalDateTime.class), NumberConversions::toLocalDateTime); + CONVERSION_DB.put(pair(BigDecimal.class, LocalDateTime.class), NumberConversions::toLocalDateTime); + CONVERSION_DB.put(pair(AtomicInteger.class, LocalDateTime.class), UNSUPPORTED); + CONVERSION_DB.put(pair(AtomicLong.class, LocalDateTime.class), NumberConversions::toLocalDateTime); + CONVERSION_DB.put(pair(java.sql.Date.class, LocalDateTime.class), DateConversions::toLocalDateTime); + CONVERSION_DB.put(pair(Timestamp.class, LocalDateTime.class), DateConversions::toLocalDateTime); + CONVERSION_DB.put(pair(Date.class, LocalDateTime.class), DateConversions::toLocalDateTime); + CONVERSION_DB.put(pair(Instant.class, LocalDateTime.class), InstantConversions::toLocalDateTime); + CONVERSION_DB.put(pair(LocalDateTime.class, LocalDateTime.class), LocalDateTimeConversions::toLocalDateTime); + CONVERSION_DB.put(pair(LocalDate.class, LocalDateTime.class), LocalDateConversions::toLocalDateTime); + CONVERSION_DB.put(pair(ZonedDateTime.class, LocalDateTime.class), ZonedDateTimeConversions::toLocalDateTime); + CONVERSION_DB.put(pair(Calendar.class, LocalDateTime.class), CalendarConversions::toLocalDateTime); + CONVERSION_DB.put(pair(Number.class, LocalDateTime.class), NumberConversions::toLocalDateTime); + CONVERSION_DB.put(pair(Map.class, LocalDateTime.class), MapConversions::toLocalDateTime); + CONVERSION_DB.put(pair(String.class, LocalDateTime.class), StringConversions::toLocalDateTime); + CONVERSION_DB.put(pair(OffsetDateTime.class, LocalDateTime.class), OffsetDateTimeConversions::toLocalDateTime); // LocalTime conversions supported - DEFAULT_FACTORY.put(pair(Void.class, LocalTime.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, LocalTime.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Short.class, LocalTime.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Integer.class, LocalTime.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Long.class, LocalTime.class), NumberConversions::toLocalTime); - DEFAULT_FACTORY.put(pair(Double.class, LocalTime.class), NumberConversions::toLocalTime); - DEFAULT_FACTORY.put(pair(BigInteger.class, LocalTime.class), NumberConversions::toLocalTime); - DEFAULT_FACTORY.put(pair(BigDecimal.class, LocalTime.class), NumberConversions::toLocalDateTime); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, LocalTime.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(AtomicLong.class, LocalTime.class), NumberConversions::toLocalTime); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, LocalTime.class), DateConversions::toLocalTime); - DEFAULT_FACTORY.put(pair(Timestamp.class, LocalTime.class), DateConversions::toLocalTime); - DEFAULT_FACTORY.put(pair(Date.class, LocalTime.class), DateConversions::toLocalTime); - DEFAULT_FACTORY.put(pair(Instant.class, LocalTime.class), InstantConversions::toLocalTime); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, LocalTime.class), LocalDateTimeConversions::toLocalTime); - DEFAULT_FACTORY.put(pair(LocalDate.class, LocalTime.class), LocalDateConversions::toLocalTime); - DEFAULT_FACTORY.put(pair(LocalTime.class, LocalTime.class), Converter::identity); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, LocalTime.class), ZonedDateTimeConversions::toLocalTime); - DEFAULT_FACTORY.put(pair(Calendar.class, LocalTime.class), CalendarConversions::toLocalTime); - DEFAULT_FACTORY.put(pair(Number.class, LocalTime.class), NumberConversions::toLocalTime); - DEFAULT_FACTORY.put(pair(Map.class, LocalTime.class), MapConversions::toLocalTime); - DEFAULT_FACTORY.put(pair(String.class, LocalTime.class), StringConversions::toLocalTime); - DEFAULT_FACTORY.put(pair(OffsetDateTime.class, LocalTime.class), OffsetDateTimeConversions::toLocalTime); + CONVERSION_DB.put(pair(Void.class, LocalTime.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, LocalTime.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Short.class, LocalTime.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Integer.class, LocalTime.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Long.class, LocalTime.class), NumberConversions::toLocalTime); + CONVERSION_DB.put(pair(Double.class, LocalTime.class), NumberConversions::toLocalTime); + CONVERSION_DB.put(pair(BigInteger.class, LocalTime.class), NumberConversions::toLocalTime); + CONVERSION_DB.put(pair(BigDecimal.class, LocalTime.class), NumberConversions::toLocalDateTime); + CONVERSION_DB.put(pair(AtomicInteger.class, LocalTime.class), UNSUPPORTED); + CONVERSION_DB.put(pair(AtomicLong.class, LocalTime.class), NumberConversions::toLocalTime); + CONVERSION_DB.put(pair(java.sql.Date.class, LocalTime.class), DateConversions::toLocalTime); + CONVERSION_DB.put(pair(Timestamp.class, LocalTime.class), DateConversions::toLocalTime); + CONVERSION_DB.put(pair(Date.class, LocalTime.class), DateConversions::toLocalTime); + CONVERSION_DB.put(pair(Instant.class, LocalTime.class), InstantConversions::toLocalTime); + CONVERSION_DB.put(pair(LocalDateTime.class, LocalTime.class), LocalDateTimeConversions::toLocalTime); + CONVERSION_DB.put(pair(LocalDate.class, LocalTime.class), LocalDateConversions::toLocalTime); + CONVERSION_DB.put(pair(LocalTime.class, LocalTime.class), Converter::identity); + CONVERSION_DB.put(pair(ZonedDateTime.class, LocalTime.class), ZonedDateTimeConversions::toLocalTime); + CONVERSION_DB.put(pair(Calendar.class, LocalTime.class), CalendarConversions::toLocalTime); + CONVERSION_DB.put(pair(Number.class, LocalTime.class), NumberConversions::toLocalTime); + CONVERSION_DB.put(pair(Map.class, LocalTime.class), MapConversions::toLocalTime); + CONVERSION_DB.put(pair(String.class, LocalTime.class), StringConversions::toLocalTime); + CONVERSION_DB.put(pair(OffsetDateTime.class, LocalTime.class), OffsetDateTimeConversions::toLocalTime); // ZonedDateTime conversions supported - DEFAULT_FACTORY.put(pair(Void.class, ZonedDateTime.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, ZonedDateTime.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Short.class, ZonedDateTime.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Integer.class, ZonedDateTime.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Long.class, ZonedDateTime.class), NumberConversions::toZonedDateTime); - DEFAULT_FACTORY.put(pair(Double.class, ZonedDateTime.class), NumberConversions::toZonedDateTime); - DEFAULT_FACTORY.put(pair(BigInteger.class, ZonedDateTime.class), NumberConversions::toZonedDateTime); - DEFAULT_FACTORY.put(pair(BigDecimal.class, ZonedDateTime.class), NumberConversions::toZonedDateTime); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, ZonedDateTime.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(AtomicLong.class, ZonedDateTime.class), NumberConversions::toZonedDateTime); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, ZonedDateTime.class), DateConversions::toZonedDateTime); - DEFAULT_FACTORY.put(pair(Timestamp.class, ZonedDateTime.class), DateConversions::toZonedDateTime); - DEFAULT_FACTORY.put(pair(Date.class, ZonedDateTime.class), DateConversions::toZonedDateTime); - DEFAULT_FACTORY.put(pair(Instant.class, ZonedDateTime.class), InstantConversions::toZonedDateTime); - DEFAULT_FACTORY.put(pair(LocalDate.class, ZonedDateTime.class), LocalDateConversions::toZonedDateTime); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, ZonedDateTime.class), LocalDateTimeConversions::toZonedDateTime); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, ZonedDateTime.class), Converter::identity); - DEFAULT_FACTORY.put(pair(Calendar.class, ZonedDateTime.class), CalendarConversions::toZonedDateTime); - DEFAULT_FACTORY.put(pair(Number.class, ZonedDateTime.class), NumberConversions::toZonedDateTime); - DEFAULT_FACTORY.put(pair(Map.class, ZonedDateTime.class), MapConversions::toZonedDateTime); - DEFAULT_FACTORY.put(pair(String.class, ZonedDateTime.class), StringConversions::toZonedDateTime); + CONVERSION_DB.put(pair(Void.class, ZonedDateTime.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, ZonedDateTime.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Short.class, ZonedDateTime.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Integer.class, ZonedDateTime.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Long.class, ZonedDateTime.class), NumberConversions::toZonedDateTime); + CONVERSION_DB.put(pair(Double.class, ZonedDateTime.class), NumberConversions::toZonedDateTime); + CONVERSION_DB.put(pair(BigInteger.class, ZonedDateTime.class), NumberConversions::toZonedDateTime); + CONVERSION_DB.put(pair(BigDecimal.class, ZonedDateTime.class), NumberConversions::toZonedDateTime); + CONVERSION_DB.put(pair(AtomicInteger.class, ZonedDateTime.class), UNSUPPORTED); + CONVERSION_DB.put(pair(AtomicLong.class, ZonedDateTime.class), NumberConversions::toZonedDateTime); + CONVERSION_DB.put(pair(java.sql.Date.class, ZonedDateTime.class), DateConversions::toZonedDateTime); + CONVERSION_DB.put(pair(Timestamp.class, ZonedDateTime.class), DateConversions::toZonedDateTime); + CONVERSION_DB.put(pair(Date.class, ZonedDateTime.class), DateConversions::toZonedDateTime); + CONVERSION_DB.put(pair(Instant.class, ZonedDateTime.class), InstantConversions::toZonedDateTime); + CONVERSION_DB.put(pair(LocalDate.class, ZonedDateTime.class), LocalDateConversions::toZonedDateTime); + CONVERSION_DB.put(pair(LocalDateTime.class, ZonedDateTime.class), LocalDateTimeConversions::toZonedDateTime); + CONVERSION_DB.put(pair(ZonedDateTime.class, ZonedDateTime.class), Converter::identity); + CONVERSION_DB.put(pair(Calendar.class, ZonedDateTime.class), CalendarConversions::toZonedDateTime); + CONVERSION_DB.put(pair(Number.class, ZonedDateTime.class), NumberConversions::toZonedDateTime); + CONVERSION_DB.put(pair(Map.class, ZonedDateTime.class), MapConversions::toZonedDateTime); + CONVERSION_DB.put(pair(String.class, ZonedDateTime.class), StringConversions::toZonedDateTime); // toOffsetDateTime - DEFAULT_FACTORY.put(pair(Void.class, OffsetDateTime.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(OffsetDateTime.class, OffsetDateTime.class), Converter::identity); - DEFAULT_FACTORY.put(pair(Map.class, OffsetDateTime.class), MapConversions::toOffsetDateTime); - DEFAULT_FACTORY.put(pair(String.class, OffsetDateTime.class), StringConversions::toOffsetDateTime); + CONVERSION_DB.put(pair(Void.class, OffsetDateTime.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(OffsetDateTime.class, OffsetDateTime.class), Converter::identity); + CONVERSION_DB.put(pair(Map.class, OffsetDateTime.class), MapConversions::toOffsetDateTime); + CONVERSION_DB.put(pair(String.class, OffsetDateTime.class), StringConversions::toOffsetDateTime); // toOffsetTime - DEFAULT_FACTORY.put(pair(Void.class, OffsetTime.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(OffsetTime.class, OffsetTime.class), Converter::identity); - DEFAULT_FACTORY.put(pair(OffsetDateTime.class, OffsetTime.class), OffsetDateTimeConversions::toOffsetTime); - DEFAULT_FACTORY.put(pair(Map.class, OffsetTime.class), MapConversions::toOffsetTime); - DEFAULT_FACTORY.put(pair(String.class, OffsetTime.class), StringConversions::toOffsetTime); + CONVERSION_DB.put(pair(Void.class, OffsetTime.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(OffsetTime.class, OffsetTime.class), Converter::identity); + CONVERSION_DB.put(pair(OffsetDateTime.class, OffsetTime.class), OffsetDateTimeConversions::toOffsetTime); + CONVERSION_DB.put(pair(Map.class, OffsetTime.class), MapConversions::toOffsetTime); + CONVERSION_DB.put(pair(String.class, OffsetTime.class), StringConversions::toOffsetTime); // UUID conversions supported - DEFAULT_FACTORY.put(pair(Void.class, UUID.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(UUID.class, UUID.class), Converter::identity); - DEFAULT_FACTORY.put(pair(String.class, UUID.class), StringConversions::toUUID); - DEFAULT_FACTORY.put(pair(BigInteger.class, UUID.class), NumberConversions::bigIntegerToUUID); - DEFAULT_FACTORY.put(pair(BigDecimal.class, UUID.class), NumberConversions::bigDecimalToUUID); - DEFAULT_FACTORY.put(pair(Map.class, UUID.class), MapConversions::toUUID); + CONVERSION_DB.put(pair(Void.class, UUID.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(UUID.class, UUID.class), Converter::identity); + CONVERSION_DB.put(pair(String.class, UUID.class), StringConversions::toUUID); + CONVERSION_DB.put(pair(BigInteger.class, UUID.class), NumberConversions::bigIntegerToUUID); + CONVERSION_DB.put(pair(BigDecimal.class, UUID.class), NumberConversions::bigDecimalToUUID); + CONVERSION_DB.put(pair(Map.class, UUID.class), MapConversions::toUUID); // Class conversions supported - DEFAULT_FACTORY.put(pair(Void.class, Class.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Class.class, Class.class), Converter::identity); - DEFAULT_FACTORY.put(pair(Map.class, Class.class), MapConversions::toClass); - DEFAULT_FACTORY.put(pair(String.class, Class.class), StringConversions::toClass); + CONVERSION_DB.put(pair(Void.class, Class.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Class.class, Class.class), Converter::identity); + CONVERSION_DB.put(pair(Map.class, Class.class), MapConversions::toClass); + CONVERSION_DB.put(pair(String.class, Class.class), StringConversions::toClass); // String conversions supported - DEFAULT_FACTORY.put(pair(Void.class, String.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(Short.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(Integer.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(Long.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(Float.class, String.class), NumberConversions::floatToString); - DEFAULT_FACTORY.put(pair(Double.class, String.class), NumberConversions::doubleToString); - DEFAULT_FACTORY.put(pair(Boolean.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(Character.class, String.class), CharacterConversions::toString); - DEFAULT_FACTORY.put(pair(BigInteger.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(BigDecimal.class, String.class), NumberConversions::bigDecimalToString); - DEFAULT_FACTORY.put(pair(AtomicBoolean.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(AtomicLong.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(byte[].class, String.class), ByteArrayConversions::toString); - DEFAULT_FACTORY.put(pair(char[].class, String.class), CharArrayConversions::toString); - DEFAULT_FACTORY.put(pair(Character[].class, String.class), CharacterArrayConversions::toString); - DEFAULT_FACTORY.put(pair(ByteBuffer.class, String.class), ByteBufferConversions::toString); - DEFAULT_FACTORY.put(pair(CharBuffer.class, String.class), CharBufferConversions::toString); - DEFAULT_FACTORY.put(pair(Class.class, String.class), ClassConversions::toString); - DEFAULT_FACTORY.put(pair(Date.class, String.class), DateConversions::dateToString); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, String.class), DateConversions::sqlDateToString); - DEFAULT_FACTORY.put(pair(Timestamp.class, String.class), DateConversions::timestampToString); - DEFAULT_FACTORY.put(pair(LocalDate.class, String.class), LocalDateConversions::toString); - DEFAULT_FACTORY.put(pair(LocalTime.class, String.class), LocalTimeConversions::toString); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, String.class), LocalDateTimeConversions::toString); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, String.class), ZonedDateTimeConversions::toString); - DEFAULT_FACTORY.put(pair(UUID.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(Calendar.class, String.class), CalendarConversions::toString); - DEFAULT_FACTORY.put(pair(Number.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(Map.class, String.class), MapConversions::toString); - DEFAULT_FACTORY.put(pair(Enum.class, String.class), StringConversions::enumToString); - DEFAULT_FACTORY.put(pair(String.class, String.class), Converter::identity); - DEFAULT_FACTORY.put(pair(Duration.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(Instant.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(LocalTime.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(MonthDay.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(YearMonth.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(Period.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(ZoneId.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(ZoneOffset.class, String.class), StringConversions::toString); - DEFAULT_FACTORY.put(pair(OffsetTime.class, String.class), OffsetTimeConversions::toString); - DEFAULT_FACTORY.put(pair(OffsetDateTime.class, String.class), OffsetDateTimeConversions::toString); - DEFAULT_FACTORY.put(pair(Year.class, String.class), YearConversions::toString); + CONVERSION_DB.put(pair(Void.class, String.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(Short.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(Integer.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(Long.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(Float.class, String.class), NumberConversions::floatToString); + CONVERSION_DB.put(pair(Double.class, String.class), NumberConversions::doubleToString); + CONVERSION_DB.put(pair(Boolean.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(Character.class, String.class), CharacterConversions::toString); + CONVERSION_DB.put(pair(BigInteger.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(BigDecimal.class, String.class), NumberConversions::bigDecimalToString); + CONVERSION_DB.put(pair(AtomicBoolean.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(AtomicInteger.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(AtomicLong.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(byte[].class, String.class), ByteArrayConversions::toString); + CONVERSION_DB.put(pair(char[].class, String.class), CharArrayConversions::toString); + CONVERSION_DB.put(pair(Character[].class, String.class), CharacterArrayConversions::toString); + CONVERSION_DB.put(pair(ByteBuffer.class, String.class), ByteBufferConversions::toString); + CONVERSION_DB.put(pair(CharBuffer.class, String.class), CharBufferConversions::toString); + CONVERSION_DB.put(pair(Class.class, String.class), ClassConversions::toString); + CONVERSION_DB.put(pair(Date.class, String.class), DateConversions::dateToString); + CONVERSION_DB.put(pair(java.sql.Date.class, String.class), DateConversions::sqlDateToString); + CONVERSION_DB.put(pair(Timestamp.class, String.class), DateConversions::timestampToString); + CONVERSION_DB.put(pair(LocalDate.class, String.class), LocalDateConversions::toString); + CONVERSION_DB.put(pair(LocalTime.class, String.class), LocalTimeConversions::toString); + CONVERSION_DB.put(pair(LocalDateTime.class, String.class), LocalDateTimeConversions::toString); + CONVERSION_DB.put(pair(ZonedDateTime.class, String.class), ZonedDateTimeConversions::toString); + CONVERSION_DB.put(pair(UUID.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(Calendar.class, String.class), CalendarConversions::toString); + CONVERSION_DB.put(pair(Number.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(Map.class, String.class), MapConversions::toString); + CONVERSION_DB.put(pair(Enum.class, String.class), StringConversions::enumToString); + CONVERSION_DB.put(pair(String.class, String.class), Converter::identity); + CONVERSION_DB.put(pair(Duration.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(Instant.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(LocalTime.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(MonthDay.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(YearMonth.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(Period.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(ZoneId.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(ZoneOffset.class, String.class), StringConversions::toString); + CONVERSION_DB.put(pair(OffsetTime.class, String.class), OffsetTimeConversions::toString); + CONVERSION_DB.put(pair(OffsetDateTime.class, String.class), OffsetDateTimeConversions::toString); + CONVERSION_DB.put(pair(Year.class, String.class), YearConversions::toString); // Duration conversions supported - DEFAULT_FACTORY.put(pair(Void.class, Duration.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Duration.class, Duration.class), Converter::identity); - DEFAULT_FACTORY.put(pair(String.class, Duration.class), StringConversions::toDuration); - DEFAULT_FACTORY.put(pair(Map.class, Duration.class), MapConversions::toDuration); + CONVERSION_DB.put(pair(Void.class, Duration.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Duration.class, Duration.class), Converter::identity); + CONVERSION_DB.put(pair(String.class, Duration.class), StringConversions::toDuration); + CONVERSION_DB.put(pair(Map.class, Duration.class), MapConversions::toDuration); // Instant conversions supported - DEFAULT_FACTORY.put(pair(Void.class, Instant.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Instant.class, Instant.class), Converter::identity); - DEFAULT_FACTORY.put(pair(Byte.class, Instant.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Short.class, Instant.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Integer.class, Instant.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Long.class, Instant.class), NumberConversions::toInstant); - DEFAULT_FACTORY.put(pair(Double.class, Instant.class), NumberConversions::toInstant); - DEFAULT_FACTORY.put(pair(BigInteger.class, Instant.class), NumberConversions::toInstant); - DEFAULT_FACTORY.put(pair(BigDecimal.class, Instant.class), NumberConversions::toInstant); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, Instant.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(AtomicLong.class, Instant.class), NumberConversions::toInstant); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, Instant.class), DateConversions::toInstant); - DEFAULT_FACTORY.put(pair(Timestamp.class, Instant.class), DateConversions::toInstant); - DEFAULT_FACTORY.put(pair(Date.class, Instant.class), DateConversions::toInstant); - DEFAULT_FACTORY.put(pair(LocalDate.class, Instant.class), LocalDateConversions::toInstant); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, Instant.class), LocalDateTimeConversions::toInstant); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, Instant.class), ZonedDateTimeConversions::toInstant); - DEFAULT_FACTORY.put(pair(Calendar.class, Instant.class), CalendarConversions::toInstant); - DEFAULT_FACTORY.put(pair(Number.class, Instant.class), NumberConversions::toInstant); - DEFAULT_FACTORY.put(pair(String.class, Instant.class), StringConversions::toInstant); - DEFAULT_FACTORY.put(pair(Map.class, Instant.class), MapConversions::toInstant); - DEFAULT_FACTORY.put(pair(OffsetDateTime.class, Instant.class), OffsetDateTimeConversions::toInstant); + CONVERSION_DB.put(pair(Void.class, Instant.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Instant.class, Instant.class), Converter::identity); + CONVERSION_DB.put(pair(Byte.class, Instant.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Short.class, Instant.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Integer.class, Instant.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Long.class, Instant.class), NumberConversions::toInstant); + CONVERSION_DB.put(pair(Double.class, Instant.class), NumberConversions::toInstant); + CONVERSION_DB.put(pair(BigInteger.class, Instant.class), NumberConversions::toInstant); + CONVERSION_DB.put(pair(BigDecimal.class, Instant.class), NumberConversions::toInstant); + CONVERSION_DB.put(pair(AtomicInteger.class, Instant.class), UNSUPPORTED); + CONVERSION_DB.put(pair(AtomicLong.class, Instant.class), NumberConversions::toInstant); + CONVERSION_DB.put(pair(java.sql.Date.class, Instant.class), DateConversions::toInstant); + CONVERSION_DB.put(pair(Timestamp.class, Instant.class), DateConversions::toInstant); + CONVERSION_DB.put(pair(Date.class, Instant.class), DateConversions::toInstant); + CONVERSION_DB.put(pair(LocalDate.class, Instant.class), LocalDateConversions::toInstant); + CONVERSION_DB.put(pair(LocalDateTime.class, Instant.class), LocalDateTimeConversions::toInstant); + CONVERSION_DB.put(pair(ZonedDateTime.class, Instant.class), ZonedDateTimeConversions::toInstant); + CONVERSION_DB.put(pair(Calendar.class, Instant.class), CalendarConversions::toInstant); + CONVERSION_DB.put(pair(Number.class, Instant.class), NumberConversions::toInstant); + CONVERSION_DB.put(pair(String.class, Instant.class), StringConversions::toInstant); + CONVERSION_DB.put(pair(Map.class, Instant.class), MapConversions::toInstant); + CONVERSION_DB.put(pair(OffsetDateTime.class, Instant.class), OffsetDateTimeConversions::toInstant); // ZoneId conversions supported - DEFAULT_FACTORY.put(pair(Void.class, ZoneId.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(ZoneId.class, ZoneId.class), Converter::identity); - DEFAULT_FACTORY.put(pair(String.class, ZoneId.class), StringConversions::toZoneId); - DEFAULT_FACTORY.put(pair(Map.class, ZoneId.class), MapConversions::toZoneId); + CONVERSION_DB.put(pair(Void.class, ZoneId.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(ZoneId.class, ZoneId.class), Converter::identity); + CONVERSION_DB.put(pair(String.class, ZoneId.class), StringConversions::toZoneId); + CONVERSION_DB.put(pair(Map.class, ZoneId.class), MapConversions::toZoneId); // ZoneOffset conversions supported - DEFAULT_FACTORY.put(pair(Void.class, ZoneOffset.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(ZoneOffset.class, ZoneOffset.class), Converter::identity); - DEFAULT_FACTORY.put(pair(String.class, ZoneOffset.class), StringConversions::toZoneOffset); - DEFAULT_FACTORY.put(pair(Map.class, ZoneOffset.class), MapConversions::toZoneOffset); + CONVERSION_DB.put(pair(Void.class, ZoneOffset.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(ZoneOffset.class, ZoneOffset.class), Converter::identity); + CONVERSION_DB.put(pair(String.class, ZoneOffset.class), StringConversions::toZoneOffset); + CONVERSION_DB.put(pair(Map.class, ZoneOffset.class), MapConversions::toZoneOffset); // MonthDay conversions supported - DEFAULT_FACTORY.put(pair(Void.class, MonthDay.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(MonthDay.class, MonthDay.class), Converter::identity); - DEFAULT_FACTORY.put(pair(String.class, MonthDay.class), StringConversions::toMonthDay); - DEFAULT_FACTORY.put(pair(Map.class, MonthDay.class), MapConversions::toMonthDay); + CONVERSION_DB.put(pair(Void.class, MonthDay.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(MonthDay.class, MonthDay.class), Converter::identity); + CONVERSION_DB.put(pair(String.class, MonthDay.class), StringConversions::toMonthDay); + CONVERSION_DB.put(pair(Map.class, MonthDay.class), MapConversions::toMonthDay); // YearMonth conversions supported - DEFAULT_FACTORY.put(pair(Void.class, YearMonth.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(YearMonth.class, YearMonth.class), Converter::identity); - DEFAULT_FACTORY.put(pair(String.class, YearMonth.class), StringConversions::toYearMonth); - DEFAULT_FACTORY.put(pair(Map.class, YearMonth.class), MapConversions::toYearMonth); + CONVERSION_DB.put(pair(Void.class, YearMonth.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(YearMonth.class, YearMonth.class), Converter::identity); + CONVERSION_DB.put(pair(String.class, YearMonth.class), StringConversions::toYearMonth); + CONVERSION_DB.put(pair(Map.class, YearMonth.class), MapConversions::toYearMonth); // Period conversions supported - DEFAULT_FACTORY.put(pair(Void.class, Period.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Period.class, Period.class), Converter::identity); - DEFAULT_FACTORY.put(pair(String.class, Period.class), StringConversions::toPeriod); - DEFAULT_FACTORY.put(pair(Map.class, Period.class), MapConversions::toPeriod); + CONVERSION_DB.put(pair(Void.class, Period.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Period.class, Period.class), Converter::identity); + CONVERSION_DB.put(pair(String.class, Period.class), StringConversions::toPeriod); + CONVERSION_DB.put(pair(Map.class, Period.class), MapConversions::toPeriod); // toStringBuffer - DEFAULT_FACTORY.put(pair(Void.class, StringBuffer.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(String.class, StringBuffer.class), StringConversions::toStringBuffer); - DEFAULT_FACTORY.put(pair(StringBuilder.class, StringBuffer.class), StringConversions::toStringBuffer); - DEFAULT_FACTORY.put(pair(StringBuffer.class, StringBuffer.class), StringConversions::toStringBuffer); - DEFAULT_FACTORY.put(pair(ByteBuffer.class, StringBuffer.class), ByteBufferConversions::toStringBuffer); - DEFAULT_FACTORY.put(pair(CharBuffer.class, StringBuffer.class), CharBufferConversions::toStringBuffer); - DEFAULT_FACTORY.put(pair(Character[].class, StringBuffer.class), CharacterArrayConversions::toStringBuffer); - DEFAULT_FACTORY.put(pair(char[].class, StringBuffer.class), CharArrayConversions::toStringBuffer); - DEFAULT_FACTORY.put(pair(byte[].class, StringBuffer.class), ByteArrayConversions::toStringBuffer); + CONVERSION_DB.put(pair(Void.class, StringBuffer.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(String.class, StringBuffer.class), StringConversions::toStringBuffer); + CONVERSION_DB.put(pair(StringBuilder.class, StringBuffer.class), StringConversions::toStringBuffer); + CONVERSION_DB.put(pair(StringBuffer.class, StringBuffer.class), StringConversions::toStringBuffer); + CONVERSION_DB.put(pair(ByteBuffer.class, StringBuffer.class), ByteBufferConversions::toStringBuffer); + CONVERSION_DB.put(pair(CharBuffer.class, StringBuffer.class), CharBufferConversions::toStringBuffer); + CONVERSION_DB.put(pair(Character[].class, StringBuffer.class), CharacterArrayConversions::toStringBuffer); + CONVERSION_DB.put(pair(char[].class, StringBuffer.class), CharArrayConversions::toStringBuffer); + CONVERSION_DB.put(pair(byte[].class, StringBuffer.class), ByteArrayConversions::toStringBuffer); // toStringBuilder - DEFAULT_FACTORY.put(pair(Void.class, StringBuilder.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(String.class, StringBuilder.class), StringConversions::toStringBuilder); - DEFAULT_FACTORY.put(pair(StringBuilder.class, StringBuilder.class), StringConversions::toStringBuilder); - DEFAULT_FACTORY.put(pair(StringBuffer.class, StringBuilder.class), StringConversions::toStringBuilder); - DEFAULT_FACTORY.put(pair(ByteBuffer.class, StringBuilder.class), ByteBufferConversions::toStringBuilder); - DEFAULT_FACTORY.put(pair(CharBuffer.class, StringBuilder.class), CharBufferConversions::toStringBuilder); - DEFAULT_FACTORY.put(pair(Character[].class, StringBuilder.class), CharacterArrayConversions::toStringBuilder); - DEFAULT_FACTORY.put(pair(char[].class, StringBuilder.class), CharArrayConversions::toStringBuilder); - DEFAULT_FACTORY.put(pair(byte[].class, StringBuilder.class), ByteArrayConversions::toStringBuilder); + CONVERSION_DB.put(pair(Void.class, StringBuilder.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(String.class, StringBuilder.class), StringConversions::toStringBuilder); + CONVERSION_DB.put(pair(StringBuilder.class, StringBuilder.class), StringConversions::toStringBuilder); + CONVERSION_DB.put(pair(StringBuffer.class, StringBuilder.class), StringConversions::toStringBuilder); + CONVERSION_DB.put(pair(ByteBuffer.class, StringBuilder.class), ByteBufferConversions::toStringBuilder); + CONVERSION_DB.put(pair(CharBuffer.class, StringBuilder.class), CharBufferConversions::toStringBuilder); + CONVERSION_DB.put(pair(Character[].class, StringBuilder.class), CharacterArrayConversions::toStringBuilder); + CONVERSION_DB.put(pair(char[].class, StringBuilder.class), CharArrayConversions::toStringBuilder); + CONVERSION_DB.put(pair(byte[].class, StringBuilder.class), ByteArrayConversions::toStringBuilder); // toByteArray - DEFAULT_FACTORY.put(pair(Void.class, byte[].class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(String.class, byte[].class), StringConversions::toByteArray); - DEFAULT_FACTORY.put(pair(StringBuilder.class, byte[].class), StringConversions::toByteArray); - DEFAULT_FACTORY.put(pair(StringBuffer.class, byte[].class), StringConversions::toByteArray); - DEFAULT_FACTORY.put(pair(ByteBuffer.class, byte[].class), ByteBufferConversions::toByteArray); - DEFAULT_FACTORY.put(pair(CharBuffer.class, byte[].class), CharBufferConversions::toByteArray); - DEFAULT_FACTORY.put(pair(char[].class, byte[].class), CharArrayConversions::toByteArray); - DEFAULT_FACTORY.put(pair(byte[].class, byte[].class), Converter::identity); + CONVERSION_DB.put(pair(Void.class, byte[].class), VoidConversions::toNull); + CONVERSION_DB.put(pair(String.class, byte[].class), StringConversions::toByteArray); + CONVERSION_DB.put(pair(StringBuilder.class, byte[].class), StringConversions::toByteArray); + CONVERSION_DB.put(pair(StringBuffer.class, byte[].class), StringConversions::toByteArray); + CONVERSION_DB.put(pair(ByteBuffer.class, byte[].class), ByteBufferConversions::toByteArray); + CONVERSION_DB.put(pair(CharBuffer.class, byte[].class), CharBufferConversions::toByteArray); + CONVERSION_DB.put(pair(char[].class, byte[].class), CharArrayConversions::toByteArray); + CONVERSION_DB.put(pair(byte[].class, byte[].class), Converter::identity); // toCharArray - DEFAULT_FACTORY.put(pair(Void.class, char[].class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Void.class, Character[].class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(String.class, char[].class), StringConversions::toCharArray); - DEFAULT_FACTORY.put(pair(StringBuilder.class, char[].class), StringConversions::toCharArray); - DEFAULT_FACTORY.put(pair(StringBuffer.class, char[].class), StringConversions::toCharArray); - DEFAULT_FACTORY.put(pair(ByteBuffer.class, char[].class), ByteBufferConversions::toCharArray); - DEFAULT_FACTORY.put(pair(CharBuffer.class, char[].class), CharBufferConversions::toCharArray); - DEFAULT_FACTORY.put(pair(char[].class, char[].class), CharArrayConversions::toCharArray); - DEFAULT_FACTORY.put(pair(byte[].class, char[].class), ByteArrayConversions::toCharArray); + CONVERSION_DB.put(pair(Void.class, char[].class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Void.class, Character[].class), VoidConversions::toNull); + CONVERSION_DB.put(pair(String.class, char[].class), StringConversions::toCharArray); + CONVERSION_DB.put(pair(StringBuilder.class, char[].class), StringConversions::toCharArray); + CONVERSION_DB.put(pair(StringBuffer.class, char[].class), StringConversions::toCharArray); + CONVERSION_DB.put(pair(ByteBuffer.class, char[].class), ByteBufferConversions::toCharArray); + CONVERSION_DB.put(pair(CharBuffer.class, char[].class), CharBufferConversions::toCharArray); + CONVERSION_DB.put(pair(char[].class, char[].class), CharArrayConversions::toCharArray); + CONVERSION_DB.put(pair(byte[].class, char[].class), ByteArrayConversions::toCharArray); // toCharBuffer - DEFAULT_FACTORY.put(pair(Void.class, CharBuffer.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(String.class, CharBuffer.class), StringConversions::toCharBuffer); - DEFAULT_FACTORY.put(pair(StringBuilder.class, CharBuffer.class), StringConversions::toCharBuffer); - DEFAULT_FACTORY.put(pair(StringBuffer.class, CharBuffer.class), StringConversions::toCharBuffer); - DEFAULT_FACTORY.put(pair(ByteBuffer.class, CharBuffer.class), ByteBufferConversions::toCharBuffer); - DEFAULT_FACTORY.put(pair(CharBuffer.class, CharBuffer.class), CharBufferConversions::toCharBuffer); - DEFAULT_FACTORY.put(pair(char[].class, CharBuffer.class), CharArrayConversions::toCharBuffer); - DEFAULT_FACTORY.put(pair(byte[].class, CharBuffer.class), ByteArrayConversions::toCharBuffer); + CONVERSION_DB.put(pair(Void.class, CharBuffer.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(String.class, CharBuffer.class), StringConversions::toCharBuffer); + CONVERSION_DB.put(pair(StringBuilder.class, CharBuffer.class), StringConversions::toCharBuffer); + CONVERSION_DB.put(pair(StringBuffer.class, CharBuffer.class), StringConversions::toCharBuffer); + CONVERSION_DB.put(pair(ByteBuffer.class, CharBuffer.class), ByteBufferConversions::toCharBuffer); + CONVERSION_DB.put(pair(CharBuffer.class, CharBuffer.class), CharBufferConversions::toCharBuffer); + CONVERSION_DB.put(pair(char[].class, CharBuffer.class), CharArrayConversions::toCharBuffer); + CONVERSION_DB.put(pair(byte[].class, CharBuffer.class), ByteArrayConversions::toCharBuffer); // toByteBuffer - DEFAULT_FACTORY.put(pair(Void.class, ByteBuffer.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(String.class, ByteBuffer.class), StringConversions::toByteBuffer); - DEFAULT_FACTORY.put(pair(StringBuilder.class, ByteBuffer.class), StringConversions::toByteBuffer); - DEFAULT_FACTORY.put(pair(StringBuffer.class, ByteBuffer.class), StringConversions::toByteBuffer); - DEFAULT_FACTORY.put(pair(ByteBuffer.class, ByteBuffer.class), ByteBufferConversions::toByteBuffer); - DEFAULT_FACTORY.put(pair(CharBuffer.class, ByteBuffer.class), CharBufferConversions::toByteBuffer); - DEFAULT_FACTORY.put(pair(char[].class, ByteBuffer.class), CharArrayConversions::toByteBuffer); - DEFAULT_FACTORY.put(pair(byte[].class, ByteBuffer.class), ByteArrayConversions::toByteBuffer); + CONVERSION_DB.put(pair(Void.class, ByteBuffer.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(String.class, ByteBuffer.class), StringConversions::toByteBuffer); + CONVERSION_DB.put(pair(StringBuilder.class, ByteBuffer.class), StringConversions::toByteBuffer); + CONVERSION_DB.put(pair(StringBuffer.class, ByteBuffer.class), StringConversions::toByteBuffer); + CONVERSION_DB.put(pair(ByteBuffer.class, ByteBuffer.class), ByteBufferConversions::toByteBuffer); + CONVERSION_DB.put(pair(CharBuffer.class, ByteBuffer.class), CharBufferConversions::toByteBuffer); + CONVERSION_DB.put(pair(char[].class, ByteBuffer.class), CharArrayConversions::toByteBuffer); + CONVERSION_DB.put(pair(byte[].class, ByteBuffer.class), ByteArrayConversions::toByteBuffer); // toYear - DEFAULT_FACTORY.put(pair(Void.class, Year.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Year.class, Year.class), Converter::identity); - DEFAULT_FACTORY.put(pair(Byte.class, Year.class), UNSUPPORTED); - DEFAULT_FACTORY.put(pair(Number.class, Year.class), NumberConversions::toYear); - DEFAULT_FACTORY.put(pair(String.class, Year.class), StringConversions::toYear); - DEFAULT_FACTORY.put(pair(Map.class, Year.class), MapConversions::toYear); + CONVERSION_DB.put(pair(Void.class, Year.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Year.class, Year.class), Converter::identity); + CONVERSION_DB.put(pair(Byte.class, Year.class), UNSUPPORTED); + CONVERSION_DB.put(pair(Number.class, Year.class), NumberConversions::toYear); + CONVERSION_DB.put(pair(String.class, Year.class), StringConversions::toYear); + CONVERSION_DB.put(pair(Map.class, Year.class), MapConversions::toYear); // Map conversions supported - DEFAULT_FACTORY.put(pair(Void.class, Map.class), VoidConversions::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(Short.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(Integer.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(Long.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(Float.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(Double.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(Boolean.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(Character.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(BigInteger.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(BigDecimal.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(AtomicBoolean.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(AtomicLong.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(Date.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(java.sql.Date.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(Timestamp.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(LocalDate.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(LocalDateTime.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(ZonedDateTime.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(Duration.class, Map.class), DurationConversions::toMap); - DEFAULT_FACTORY.put(pair(Instant.class, Map.class), InstantConversions::toMap); - DEFAULT_FACTORY.put(pair(LocalTime.class, Map.class), LocalTimeConversions::toMap); - DEFAULT_FACTORY.put(pair(MonthDay.class, Map.class), MonthDayConversions::toMap); - DEFAULT_FACTORY.put(pair(YearMonth.class, Map.class), YearMonthConversions::toMap); - DEFAULT_FACTORY.put(pair(Period.class, Map.class), PeriodConversions::toMap); - DEFAULT_FACTORY.put(pair(ZoneId.class, Map.class), ZoneIdConversions::toMap); - DEFAULT_FACTORY.put(pair(ZoneOffset.class, Map.class), ZoneOffsetConversions::toMap); - DEFAULT_FACTORY.put(pair(Class.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(UUID.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(Calendar.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(Number.class, Map.class), MapConversions::initMap); - DEFAULT_FACTORY.put(pair(Map.class, Map.class), MapConversions::toMap); - DEFAULT_FACTORY.put(pair(Enum.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(Void.class, Map.class), VoidConversions::toNull); + CONVERSION_DB.put(pair(Byte.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(Short.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(Integer.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(Long.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(Float.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(Double.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(Boolean.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(Character.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(BigInteger.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(BigDecimal.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(AtomicBoolean.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(AtomicInteger.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(AtomicLong.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(Date.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(java.sql.Date.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(Timestamp.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(LocalDate.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(LocalDateTime.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(ZonedDateTime.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(Duration.class, Map.class), DurationConversions::toMap); + CONVERSION_DB.put(pair(Instant.class, Map.class), InstantConversions::toMap); + CONVERSION_DB.put(pair(LocalTime.class, Map.class), LocalTimeConversions::toMap); + CONVERSION_DB.put(pair(MonthDay.class, Map.class), MonthDayConversions::toMap); + CONVERSION_DB.put(pair(YearMonth.class, Map.class), YearMonthConversions::toMap); + CONVERSION_DB.put(pair(Period.class, Map.class), PeriodConversions::toMap); + CONVERSION_DB.put(pair(ZoneId.class, Map.class), ZoneIdConversions::toMap); + CONVERSION_DB.put(pair(ZoneOffset.class, Map.class), ZoneOffsetConversions::toMap); + CONVERSION_DB.put(pair(Class.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(UUID.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(Calendar.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(Number.class, Map.class), MapConversions::initMap); + CONVERSION_DB.put(pair(Map.class, Map.class), MapConversions::toMap); + CONVERSION_DB.put(pair(Enum.class, Map.class), MapConversions::initMap); } public Converter(ConverterOptions options) { this.options = options; - this.factory = new ConcurrentHashMap<>(DEFAULT_FACTORY); + this.factory = new ConcurrentHashMap<>(CONVERSION_DB); } /** @@ -884,41 +888,8 @@ public Converter(ConverterOptions options) { * @see #getSupportedConversions() * @return An instanceof targetType class, based upon the value passed in. */ - public T convert(Object from, Class toType) { - return this.convert(from, toType, options); - } - - /** - * Turn the passed in value to the class indicated. This will allow, for - * example, a String to be passed in and be converted to a Long. - *
-     *     Examples:
-     *     Long x = convert("35", Long.class);
-     *     Date d = convert("2015/01/01", Date.class)
-     *     int y = convert(45.0, int.class)
-     *     String date = convert(date, String.class)
-     *     String date = convert(calendar, String.class)
-     *     Short t = convert(true, short.class);     // returns (short) 1 or  (short) 0
-     *     Long date = convert(calendar, long.class); // get calendar's time into long
-     *     Map containing ["_v": "75.0"]
-     *     convert(map, double.class)   // Converter will extract the value associated to the "_v" (or "value") key and convert it.
-     * 
- * - * @param from A value used to create the targetType, even though it may - * not (most likely will not) be the same data type as the targetType - * @param toType Class which indicates the targeted (final) data type. - * Please note that in addition to the 8 Java primitives, the targeted class - * can also be Date.class, String.class, BigInteger.class, BigDecimal.class, and - * many other JDK classes, including Map. For Map, often it will seek a 'value' - * field, however, for some complex objects, like UUID, it will look for specific - * fields within the Map to perform the conversion. - * @param options ConverterOptions - allows you to specify locale, ZoneId, etc. to support conversion - * operations. - * @see #getSupportedConversions() - * @return An instanceof targetType class, based upon the value passed in. - */ @SuppressWarnings("unchecked") - public T convert(Object from, Class toType, ConverterOptions options) { + public T convert(Object from, Class toType) { if (toType == null) { throw new IllegalArgumentException("toType cannot be null"); } @@ -937,7 +908,7 @@ public T convert(Object from, Class toType, ConverterOptions options) { // Direct Mapping Convert converter = factory.get(pair(sourceType, toType)); if (converter != null && converter != UNSUPPORTED) { - return (T) converter.convert(from, this, options); + return (T) converter.convert(from, this); } // Try inheritance @@ -947,7 +918,7 @@ public T convert(Object from, Class toType, ConverterOptions options) { if (!isDirectConversionSupportedFor(sourceType, toType)) { addConversion(sourceType, toType, converter); } - return (T) converter.convert(from, this, options); + return (T) converter.convert(from, this); } throw new IllegalArgumentException("Unsupported conversion, source type [" + name(from) + "] target type '" + getShortName(toType) + "'"); @@ -1155,11 +1126,11 @@ private static Class toPrimitiveWrapperClass(Class primitiveClass) { return c; } - private static T identity(T from, Converter converter, ConverterOptions options) { + private static T identity(T from, Converter converter) { return from; } - private static T unsupported(T from, Converter converter, ConverterOptions options) { + private static T unsupported(T from, Converter converter) { return null; } } diff --git a/src/main/java/com/cedarsoftware/util/convert/ConverterOptions.java b/src/main/java/com/cedarsoftware/util/convert/ConverterOptions.java index 093ec3bd..36e19e3a 100644 --- a/src/main/java/com/cedarsoftware/util/convert/ConverterOptions.java +++ b/src/main/java/com/cedarsoftware/util/convert/ConverterOptions.java @@ -26,8 +26,6 @@ * limitations under the License. */ public interface ConverterOptions { - - /** * @return {@link ZoneId} to use for source conversion when one is not provided and is required on the target * type. ie. {@link LocalDateTime}, {@link LocalDate}, or {@link String} when no zone is provided. @@ -43,8 +41,7 @@ public interface ConverterOptions { * @return Charset to use os target Charset on types that require a Charset during conversion (if required). */ default Charset getCharset() { return StandardCharsets.UTF_8; } - - + /** * @return Classloader for loading and initializing classes. */ diff --git a/src/main/java/com/cedarsoftware/util/convert/DateConversions.java b/src/main/java/com/cedarsoftware/util/convert/DateConversions.java index 65920175..5aba27fb 100644 --- a/src/main/java/com/cedarsoftware/util/convert/DateConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/DateConversions.java @@ -30,90 +30,77 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class DateConversions { +final class DateConversions { private DateConversions() {} - - static long toLong(Object from) { - return ((Date) from).getTime(); - } - - static Instant toInstant(Object from) { - return Instant.ofEpochMilli(toLong(from)); - } - - static ZonedDateTime toZonedDateTime(Object from, ConverterOptions options) { - return toInstant(from).atZone(options.getZoneId()); - } - - static long toLong(Object from, Converter converter, ConverterOptions options) { - return toLong(from); + + static ZonedDateTime toZonedDateTime(Object from, Converter converter) { + return Instant.ofEpochMilli(toLong(from, converter)).atZone(converter.getOptions().getZoneId()); } - static java.sql.Date toSqlDate(Object from, Converter converter, ConverterOptions options) { - return new java.sql.Date(toLong(from)); + static long toLong(Object from, Converter converter) { + return ((Date) from).getTime(); } - static Date toDate(Object from, Converter converter, ConverterOptions options) { - return new Date(toLong(from)); + static java.sql.Date toSqlDate(Object from, Converter converter) { + return new java.sql.Date(toLong(from, converter)); } - static Timestamp toTimestamp(Object from, Converter converter, ConverterOptions options) { - return new Timestamp(toLong(from)); + static Date toDate(Object from, Converter converter) { + return new Date(toLong(from,converter)); } - static Calendar toCalendar(Object from, Converter converter, ConverterOptions options) { - return CalendarConversions.create(toLong(from), options); + static Timestamp toTimestamp(Object from, Converter converter) { + return new Timestamp(toLong(from, converter)); } - static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) { - return BigDecimal.valueOf(toLong(from)); + static Calendar toCalendar(Object from, Converter converter) { + return CalendarConversions.create(toLong(from, converter), converter); } - static Instant toInstant(Object from, Converter converter, ConverterOptions options) { - return toInstant(from); + static BigDecimal toBigDecimal(Object from, Converter converter) { + return BigDecimal.valueOf(toLong(from, converter)); } - static ZonedDateTime toZonedDateTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options); + static Instant toInstant(Object from, Converter converter) { + return Instant.ofEpochMilli(toLong(from, converter)); } - static LocalDateTime toLocalDateTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalDateTime(); + static LocalDateTime toLocalDateTime(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalDateTime(); } - static LocalDate toLocalDate(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalDate(); + static LocalDate toLocalDate(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalDate(); } - static LocalTime toLocalTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalTime(); + static LocalTime toLocalTime(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalTime(); } - static BigInteger toBigInteger(Object from, Converter converter, ConverterOptions options) { - return BigInteger.valueOf(toLong(from)); + static BigInteger toBigInteger(Object from, Converter converter) { + return BigInteger.valueOf(toLong(from, converter)); } - static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) { - return new AtomicLong(toLong(from)); + static AtomicLong toAtomicLong(Object from, Converter converter) { + return new AtomicLong(toLong(from, converter)); } - static String dateToString(Object from, Converter converter, ConverterOptions options) { + static String dateToString(Object from, Converter converter) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); - simpleDateFormat.setTimeZone(options.getTimeZone()); + simpleDateFormat.setTimeZone(converter.getOptions().getTimeZone()); return simpleDateFormat.format(((Date) from)); } - static String sqlDateToString(Object from, Converter converter, ConverterOptions options) { + static String sqlDateToString(Object from, Converter converter) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); - simpleDateFormat.setTimeZone(options.getTimeZone()); + simpleDateFormat.setTimeZone(converter.getOptions().getTimeZone()); return simpleDateFormat.format(((Date) from)); } - static String timestampToString(Object from, Converter converter, ConverterOptions options) { + static String timestampToString(Object from, Converter converter) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); - simpleDateFormat.setTimeZone(options.getTimeZone()); + simpleDateFormat.setTimeZone(converter.getOptions().getTimeZone()); return simpleDateFormat.format(((Date) from)); } - } diff --git a/src/main/java/com/cedarsoftware/util/convert/DurationConversions.java b/src/main/java/com/cedarsoftware/util/convert/DurationConversions.java index 8692dcd6..fecb7025 100644 --- a/src/main/java/com/cedarsoftware/util/convert/DurationConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/DurationConversions.java @@ -22,11 +22,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class DurationConversions { +final class DurationConversions { private DurationConversions() {} - static Map toMap(Object from, Converter converter, ConverterOptions options) { + static Map toMap(Object from, Converter converter) { long sec = ((Duration) from).getSeconds(); long nanos = ((Duration) from).getNano(); Map target = new CompactLinkedMap<>(); diff --git a/src/main/java/com/cedarsoftware/util/convert/InstantConversions.java b/src/main/java/com/cedarsoftware/util/convert/InstantConversions.java index 96468044..c8472e84 100644 --- a/src/main/java/com/cedarsoftware/util/convert/InstantConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/InstantConversions.java @@ -32,15 +32,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class InstantConversions { +final class InstantConversions { private InstantConversions() {} - static long toLong(Object from) { - return ((Instant)from).toEpochMilli(); - } - - static Map toMap(Object from, Converter converter, ConverterOptions options) { + static Map toMap(Object from, Converter converter) { long sec = ((Instant) from).getEpochSecond(); long nanos = ((Instant) from).getNano(); Map target = new CompactLinkedMap<>(); @@ -48,63 +44,60 @@ static Map toMap(Object from, Converter converter, ConverterOptions options) { target.put("nanos", nanos); return target; } - static ZonedDateTime toZonedDateTime(Object from, ConverterOptions options) { - return ((Instant)from).atZone(options.getZoneId()); + + static ZonedDateTime toZonedDateTime(Object from, Converter converter) { + return ((Instant)from).atZone(converter.getOptions().getZoneId()); } - static long toLong(Object from, Converter converter, ConverterOptions options) { - return toLong(from); + static long toLong(Object from, Converter converter) { + return ((Instant) from).toEpochMilli(); } - static float toFloat(Object from, Converter converter, ConverterOptions options) { - return toLong(from); + static float toFloat(Object from, Converter converter) { + return toLong(from, converter); } - static double toDouble(Object from, Converter converter, ConverterOptions options) { - return toLong(from); + static double toDouble(Object from, Converter converter) { + return toLong(from, converter); } - static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) { - return new AtomicLong(toLong(from)); + static AtomicLong toAtomicLong(Object from, Converter converter) { + return new AtomicLong(toLong(from, converter)); } - static Timestamp toTimestamp(Object from, Converter converter, ConverterOptions options) { - return new Timestamp(toLong(from)); + static Timestamp toTimestamp(Object from, Converter converter) { + return new Timestamp(toLong(from, converter)); } - static java.sql.Date toSqlDate(Object from, Converter converter, ConverterOptions options) { - return new java.sql.Date(toLong(from)); + static java.sql.Date toSqlDate(Object from, Converter converter) { + return new java.sql.Date(toLong(from, converter)); } - static Date toDate(Object from, Converter converter, ConverterOptions options) { - return new Date(toLong(from)); + static Date toDate(Object from, Converter converter) { + return new Date(toLong(from, converter)); } - static Calendar toCalendar(Object from, Converter converter, ConverterOptions options) { - return CalendarConversions.create(toLong(from), options); + static Calendar toCalendar(Object from, Converter converter) { + return CalendarConversions.create(toLong(from, converter), converter); } - static BigInteger toBigInteger(Object from, Converter converter, ConverterOptions options) { - return BigInteger.valueOf(toLong(from)); - } - - static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) { - return BigDecimal.valueOf(toLong(from)); + static BigInteger toBigInteger(Object from, Converter converter) { + return BigInteger.valueOf(toLong(from, converter)); } - static ZonedDateTime toZonedDateTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options); + static BigDecimal toBigDecimal(Object from, Converter converter) { + return BigDecimal.valueOf(toLong(from, converter)); } - static LocalDateTime toLocalDateTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalDateTime(); + static LocalDateTime toLocalDateTime(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalDateTime(); } - static LocalDate toLocalDate(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalDate(); + static LocalDate toLocalDate(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalDate(); } - static LocalTime toLocalTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalTime(); + static LocalTime toLocalTime(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalTime(); } } diff --git a/src/main/java/com/cedarsoftware/util/convert/LocalDateConversions.java b/src/main/java/com/cedarsoftware/util/convert/LocalDateConversions.java index 5e7bdb44..29426bb8 100644 --- a/src/main/java/com/cedarsoftware/util/convert/LocalDateConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/LocalDateConversions.java @@ -7,6 +7,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Calendar; @@ -31,97 +32,82 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class LocalDateConversions { +final class LocalDateConversions { private LocalDateConversions() {} - private static ZonedDateTime toZonedDateTime(Object from, ConverterOptions options) { - return ((LocalDate)from).atStartOfDay(options.getZoneId()); + static Instant toInstant(Object from, Converter converter) { + return toZonedDateTime(from, converter).toInstant(); } - static Instant toInstant(Object from, ConverterOptions options) { - return toZonedDateTime(from, options).toInstant(); + static long toLong(Object from, Converter converter) { + return toInstant(from, converter).toEpochMilli(); } - static long toLong(Object from, ConverterOptions options) { - return toInstant(from, options).toEpochMilli(); + static LocalDateTime toLocalDateTime(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalDateTime(); } - static LocalDateTime toLocalDateTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalDateTime(); + static LocalDate toLocalDate(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalDate(); } - static LocalDate toLocalDate(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalDate(); + static LocalTime toLocalTime(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalTime(); } - static LocalTime toLocalTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalTime(); + static ZonedDateTime toZonedDateTime(Object from, Converter converter) { + ZoneId zoneId = converter.getOptions().getZoneId(); + return ((LocalDate) from).atStartOfDay(zoneId).withZoneSameInstant(zoneId); } - - static ZonedDateTime toZonedDateTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).withZoneSameInstant(options.getZoneId()); - } - - static Instant toInstant(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toInstant(); - } - - - static long toLong(Object from, Converter converter, ConverterOptions options) { - return toInstant(from, options).toEpochMilli(); - } - + /** * Warning: Can lose precision going from a full long down to a floating point number * @param from instance to convert * @param converter converter instance - * @param options converter options - * @return the floating point number cast from a lont. + * @return the floating point number cast from a long. */ - static float toFloat(Object from, Converter converter, ConverterOptions options) { - return toLong(from, converter, options); + static float toFloat(Object from, Converter converter) { + return toLong(from, converter); } - static double toDouble(Object from, Converter converter, ConverterOptions options) { - return toLong(from, converter, options); + static double toDouble(Object from, Converter converter) { + return toLong(from, converter); } - static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) { - return new AtomicLong(toLong(from, options)); + static AtomicLong toAtomicLong(Object from, Converter converter) { + return new AtomicLong(toLong(from, converter)); } - static Timestamp toTimestamp(Object from, Converter converter, ConverterOptions options) { - return new Timestamp(toLong(from, options)); + static Timestamp toTimestamp(Object from, Converter converter) { + return new Timestamp(toLong(from, converter)); } - static Calendar toCalendar(Object from, Converter converter, ConverterOptions options) { - ZonedDateTime time = toZonedDateTime(from, options); - GregorianCalendar calendar = new GregorianCalendar(options.getTimeZone()); + static Calendar toCalendar(Object from, Converter converter) { + ZonedDateTime time = toZonedDateTime(from, converter); + GregorianCalendar calendar = new GregorianCalendar(converter.getOptions().getTimeZone()); calendar.setTimeInMillis(time.toInstant().toEpochMilli()); return calendar; } - static java.sql.Date toSqlDate(Object from, Converter converter, ConverterOptions options) { - return new java.sql.Date(toLong(from, options)); + static java.sql.Date toSqlDate(Object from, Converter converter) { + return new java.sql.Date(toLong(from, converter)); } - static Date toDate(Object from, Converter converter, ConverterOptions options) { - return new Date(toLong(from, options)); + static Date toDate(Object from, Converter converter) { + return new Date(toLong(from, converter)); } - static BigInteger toBigInteger(Object from, Converter converter, ConverterOptions options) { - return BigInteger.valueOf(toLong(from, options)); + static BigInteger toBigInteger(Object from, Converter converter) { + return BigInteger.valueOf(toLong(from, converter)); } - static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) { - return BigDecimal.valueOf(toLong(from, options)); + static BigDecimal toBigDecimal(Object from, Converter converter) { + return BigDecimal.valueOf(toLong(from, converter)); } - static String toString(Object from, Converter converter, ConverterOptions options) { + static String toString(Object from, Converter converter) { LocalDate localDate = (LocalDate) from; return localDate.format(DateTimeFormatter.ISO_LOCAL_DATE); } - - } diff --git a/src/main/java/com/cedarsoftware/util/convert/LocalDateTimeConversions.java b/src/main/java/com/cedarsoftware/util/convert/LocalDateTimeConversions.java index 67eb877d..6cbcce3b 100644 --- a/src/main/java/com/cedarsoftware/util/convert/LocalDateTimeConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/LocalDateTimeConversions.java @@ -31,78 +31,66 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class LocalDateTimeConversions { +final class LocalDateTimeConversions { private LocalDateTimeConversions() {} - private static ZonedDateTime toZonedDateTime(Object from, ConverterOptions options) { - return ((LocalDateTime)from).atZone(options.getZoneId()); + static ZonedDateTime toZonedDateTime(Object from, Converter converter) { + return ((LocalDateTime)from).atZone(converter.getOptions().getZoneId()); } - private static Instant toInstant(Object from, ConverterOptions options) { - return toZonedDateTime(from, options).toInstant(); + static Instant toInstant(Object from, Converter converter) { + return toZonedDateTime(from, converter).toInstant(); } - private static long toLong(Object from, ConverterOptions options) { - return toInstant(from, options).toEpochMilli(); + static long toLong(Object from, Converter converter) { + return toInstant(from, converter).toEpochMilli(); } - - static ZonedDateTime toZonedDateTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options); - } - - static LocalDateTime toLocalDateTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalDateTime(); - } - - static LocalDate toLocalDate(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalDate(); - } - - static LocalTime toLocalTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalTime(); + + static LocalDateTime toLocalDateTime(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalDateTime(); } - static Instant toInstant(Object from, Converter converter, ConverterOptions options) { - return toInstant(from, options); + static LocalDate toLocalDate(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalDate(); } - static long toLong(Object from, Converter converter, ConverterOptions options) { - return toLong(from, options); + static LocalTime toLocalTime(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalTime(); } - static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) { - return new AtomicLong(toLong(from, options)); + static AtomicLong toAtomicLong(Object from, Converter converter) { + return new AtomicLong(toLong(from, converter)); } - static Timestamp toTimestamp(Object from, Converter converter, ConverterOptions options) { - return new Timestamp(toLong(from, options)); + static Timestamp toTimestamp(Object from, Converter converter) { + return new Timestamp(toLong(from, converter)); } - static Calendar toCalendar(Object from, Converter converter, ConverterOptions options) { - ZonedDateTime time = toZonedDateTime(from, options); - GregorianCalendar calendar = new GregorianCalendar(options.getTimeZone()); + static Calendar toCalendar(Object from, Converter converter) { + ZonedDateTime time = toZonedDateTime(from, converter); + GregorianCalendar calendar = new GregorianCalendar(converter.getOptions().getTimeZone()); calendar.setTimeInMillis(time.toInstant().toEpochMilli()); return calendar; } - static java.sql.Date toSqlDate(Object from, Converter converter, ConverterOptions options) { - return new java.sql.Date(toLong(from, options)); + static java.sql.Date toSqlDate(Object from, Converter converter) { + return new java.sql.Date(toLong(from, converter)); } - static Date toDate(Object from, Converter converter, ConverterOptions options) { - return new Date(toLong(from, options)); + static Date toDate(Object from, Converter converter) { + return new Date(toLong(from, converter)); } - static BigInteger toBigInteger(Object from, Converter converter, ConverterOptions options) { - return BigInteger.valueOf(toLong(from, options)); + static BigInteger toBigInteger(Object from, Converter converter) { + return BigInteger.valueOf(toLong(from, converter)); } - static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) { - return BigDecimal.valueOf(toLong(from, options)); + static BigDecimal toBigDecimal(Object from, Converter converter) { + return BigDecimal.valueOf(toLong(from, converter)); } - static String toString(Object from, Converter converter, ConverterOptions options) { + static String toString(Object from, Converter converter) { LocalDateTime localDateTime = (LocalDateTime) from; return localDateTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME); } diff --git a/src/main/java/com/cedarsoftware/util/convert/LocalTimeConversions.java b/src/main/java/com/cedarsoftware/util/convert/LocalTimeConversions.java index 0bac0862..c3c6dc3a 100644 --- a/src/main/java/com/cedarsoftware/util/convert/LocalTimeConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/LocalTimeConversions.java @@ -23,11 +23,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class LocalTimeConversions { +final class LocalTimeConversions { private LocalTimeConversions() {} - static Map toMap(Object from, Converter converter, ConverterOptions options) { + static Map toMap(Object from, Converter converter) { LocalTime localTime = (LocalTime) from; Map target = new CompactLinkedMap<>(); target.put("hour", localTime.getHour()); @@ -43,7 +43,7 @@ static Map toMap(Object from, Converter converter, ConverterOpti return target; } - static String toString(Object from, Converter converter, ConverterOptions options) { + static String toString(Object from, Converter converter) { LocalTime localTime = (LocalTime) from; return localTime.format(DateTimeFormatter.ISO_LOCAL_TIME); } diff --git a/src/main/java/com/cedarsoftware/util/convert/MapConversions.java b/src/main/java/com/cedarsoftware/util/convert/MapConversions.java index f5577b2a..4c099793 100644 --- a/src/main/java/com/cedarsoftware/util/convert/MapConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/MapConversions.java @@ -49,8 +49,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class MapConversions { - +final class MapConversions { private static final String V = "_v"; private static final String VALUE = "value"; private static final String TIME = "time"; @@ -79,283 +78,299 @@ private MapConversions() {} public static final String KEY_VALUE_ERROR_MESSAGE = "To convert from Map to %s the map must include one of the following: %s[_v], or [value] with associated values."; private static String[] UUID_PARAMS = new String[] { MOST_SIG_BITS, LEAST_SIG_BITS }; - static Object toUUID(Object from, Converter converter, ConverterOptions options) { + static Object toUUID(Object from, Converter converter) { Map map = (Map) from; + ConverterOptions options = converter.getOptions(); if (map.containsKey(MOST_SIG_BITS) && map.containsKey(LEAST_SIG_BITS)) { - long most = converter.convert(map.get(MOST_SIG_BITS), long.class, options); - long least = converter.convert(map.get(LEAST_SIG_BITS), long.class, options); + long most = converter.convert(map.get(MOST_SIG_BITS), long.class); + long least = converter.convert(map.get(LEAST_SIG_BITS), long.class); return new UUID(most, least); } - return fromValueForMultiKey(from, converter, options, UUID.class, UUID_PARAMS); + return fromValueForMultiKey(from, converter, UUID.class, UUID_PARAMS); } - static Byte toByte(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, Byte.class); + static Byte toByte(Object from, Converter converter) { + return fromValue(from, converter, Byte.class); } - static Short toShort(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, Short.class); + static Short toShort(Object from, Converter converter) { + return fromValue(from, converter, Short.class); } - static Integer toInt(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, Integer.class); + static Integer toInt(Object from, Converter converter) { + return fromValue(from, converter, Integer.class); } - static Long toLong(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, Long.class); + static Long toLong(Object from, Converter converter) { + return fromValue(from, converter, Long.class); } - static Float toFloat(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, Float.class); + static Float toFloat(Object from, Converter converter) { + return fromValue(from, converter, Float.class); } - static Double toDouble(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, Double.class); + static Double toDouble(Object from, Converter converter) { + return fromValue(from, converter, Double.class); } - static Boolean toBoolean(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, Boolean.class); + static Boolean toBoolean(Object from, Converter converter) { + return fromValue(from, converter, Boolean.class); } - static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, BigDecimal.class); + static BigDecimal toBigDecimal(Object from, Converter converter) { + return fromValue(from, converter, BigDecimal.class); } - static BigInteger toBigInteger(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, BigInteger.class); + static BigInteger toBigInteger(Object from, Converter converter) { + return fromValue(from, converter, BigInteger.class); } - static String toString(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, String.class); + static String toString(Object from, Converter converter) { + return fromValue(from, converter, String.class); } - static Character toCharacter(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, char.class); + static Character toCharacter(Object from, Converter converter) { + return fromValue(from, converter, char.class); } - static AtomicInteger toAtomicInteger(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, AtomicInteger.class); + static AtomicInteger toAtomicInteger(Object from, Converter converter) { + return fromValue(from, converter, AtomicInteger.class); } - static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, AtomicLong.class); + static AtomicLong toAtomicLong(Object from, Converter converter) { + return fromValue(from, converter, AtomicLong.class); } - static AtomicBoolean toAtomicBoolean(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, AtomicBoolean.class); + static AtomicBoolean toAtomicBoolean(Object from, Converter converter) { + return fromValue(from, converter, AtomicBoolean.class); } - static java.sql.Date toSqlDate(Object from, Converter converter, ConverterOptions options) { - return fromSingleKey(from, converter, options, TIME, java.sql.Date.class); + static java.sql.Date toSqlDate(Object from, Converter converter) { + return fromSingleKey(from, converter, TIME, java.sql.Date.class); } - static Date toDate(Object from, Converter converter, ConverterOptions options) { - return fromSingleKey(from, converter, options, TIME, Date.class); + static Date toDate(Object from, Converter converter) { + return fromSingleKey(from, converter, TIME, Date.class); } private static final String[] TIMESTAMP_PARAMS = new String[] { TIME, NANOS }; - static Timestamp toTimestamp(Object from, Converter converter, ConverterOptions options) { + static Timestamp toTimestamp(Object from, Converter converter) { Map map = (Map) from; + ConverterOptions options = converter.getOptions(); if (map.containsKey(TIME)) { - long time = converter.convert(map.get(TIME), long.class, options); - int ns = converter.convert(map.get(NANOS), int.class, options); + long time = converter.convert(map.get(TIME), long.class); + int ns = converter.convert(map.get(NANOS), int.class); Timestamp timeStamp = new Timestamp(time); timeStamp.setNanos(ns); return timeStamp; } - return fromValueForMultiKey(map, converter, options, Timestamp.class, TIMESTAMP_PARAMS); + return fromValueForMultiKey(map, converter, Timestamp.class, TIMESTAMP_PARAMS); } private static final String[] CALENDAR_PARAMS = new String[] { TIME, ZONE }; - static Calendar toCalendar(Object from, Converter converter, ConverterOptions options) { + static Calendar toCalendar(Object from, Converter converter) { Map map = (Map) from; if (map.containsKey(TIME)) { Object zoneRaw = map.get(ZONE); TimeZone tz; + ConverterOptions options = converter.getOptions(); + if (zoneRaw instanceof String) { String zone = (String) zoneRaw; tz = TimeZone.getTimeZone(zone); } else { tz = TimeZone.getTimeZone(options.getZoneId()); } + Calendar cal = Calendar.getInstance(); cal.setTimeZone(tz); - Date epochInMillis = converter.convert(map.get(TIME), Date.class, options); + Date epochInMillis = converter.convert(map.get(TIME), Date.class); cal.setTimeInMillis(epochInMillis.getTime()); return cal; } else { - return fromValueForMultiKey(map, converter, options, Calendar.class, CALENDAR_PARAMS); + return fromValueForMultiKey(map, converter, Calendar.class, CALENDAR_PARAMS); } } private static final String[] LOCAL_DATE_PARAMS = new String[] { YEAR, MONTH, DAY }; - static LocalDate toLocalDate(Object from, Converter converter, ConverterOptions options) { + static LocalDate toLocalDate(Object from, Converter converter) { Map map = (Map) from; if (map.containsKey(MONTH) && map.containsKey(DAY) && map.containsKey(YEAR)) { - int month = converter.convert(map.get(MONTH), int.class, options); - int day = converter.convert(map.get(DAY), int.class, options); - int year = converter.convert(map.get(YEAR), int.class, options); + ConverterOptions options = converter.getOptions(); + int month = converter.convert(map.get(MONTH), int.class); + int day = converter.convert(map.get(DAY), int.class); + int year = converter.convert(map.get(YEAR), int.class); return LocalDate.of(year, month, day); } else { - return fromValueForMultiKey(map, converter, options, LocalDate.class, LOCAL_DATE_PARAMS); + return fromValueForMultiKey(map, converter, LocalDate.class, LOCAL_DATE_PARAMS); } } private static final String[] LOCAL_TIME_PARAMS = new String[] { HOUR, MINUTE, SECOND, NANO }; - static LocalTime toLocalTime(Object from, Converter converter, ConverterOptions options) { + static LocalTime toLocalTime(Object from, Converter converter) { Map map = (Map) from; if (map.containsKey(HOUR) && map.containsKey(MINUTE)) { - int hour = converter.convert(map.get(HOUR), int.class, options); - int minute = converter.convert(map.get(MINUTE), int.class, options); - int second = converter.convert(map.get(SECOND), int.class, options); - int nano = converter.convert(map.get(NANO), int.class, options); + ConverterOptions options = converter.getOptions(); + int hour = converter.convert(map.get(HOUR), int.class); + int minute = converter.convert(map.get(MINUTE), int.class); + int second = converter.convert(map.get(SECOND), int.class); + int nano = converter.convert(map.get(NANO), int.class); return LocalTime.of(hour, minute, second, nano); } else { - return fromValueForMultiKey(map, converter, options, LocalTime.class, LOCAL_TIME_PARAMS); + return fromValueForMultiKey(map, converter, LocalTime.class, LOCAL_TIME_PARAMS); } } private static final String[] OFFSET_TIME_PARAMS = new String[] { HOUR, MINUTE, SECOND, NANO, OFFSET_HOUR, OFFSET_MINUTE }; - static OffsetTime toOffsetTime(Object from, Converter converter, ConverterOptions options) { + static OffsetTime toOffsetTime(Object from, Converter converter) { Map map = (Map) from; if (map.containsKey(HOUR) && map.containsKey(MINUTE)) { - int hour = converter.convert(map.get(HOUR), int.class, options); - int minute = converter.convert(map.get(MINUTE), int.class, options); - int second = converter.convert(map.get(SECOND), int.class, options); - int nano = converter.convert(map.get(NANO), int.class, options); - int offsetHour = converter.convert(map.get(OFFSET_HOUR), int.class, options); - int offsetMinute = converter.convert(map.get(OFFSET_MINUTE), int.class, options); + ConverterOptions options = converter.getOptions(); + int hour = converter.convert(map.get(HOUR), int.class); + int minute = converter.convert(map.get(MINUTE), int.class); + int second = converter.convert(map.get(SECOND), int.class); + int nano = converter.convert(map.get(NANO), int.class); + int offsetHour = converter.convert(map.get(OFFSET_HOUR), int.class); + int offsetMinute = converter.convert(map.get(OFFSET_MINUTE), int.class); ZoneOffset zoneOffset = ZoneOffset.ofHoursMinutes(offsetHour, offsetMinute); return OffsetTime.of(hour, minute, second, nano, zoneOffset); } else { - return fromValueForMultiKey(map, converter, options, OffsetTime.class, OFFSET_TIME_PARAMS); + return fromValueForMultiKey(map, converter, OffsetTime.class, OFFSET_TIME_PARAMS); } } private static final String[] OFFSET_DATE_TIME_PARAMS = new String[] { YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, NANO, OFFSET_HOUR, OFFSET_MINUTE }; - static OffsetDateTime toOffsetDateTime(Object from, Converter converter, ConverterOptions options) { + static OffsetDateTime toOffsetDateTime(Object from, Converter converter) { Map map = (Map) from; if (map.containsKey(YEAR) && map.containsKey(OFFSET_HOUR)) { - int year = converter.convert(map.get(YEAR), int.class, options); - int month = converter.convert(map.get(MONTH), int.class, options); - int day = converter.convert(map.get(DAY), int.class, options); - int hour = converter.convert(map.get(HOUR), int.class, options); - int minute = converter.convert(map.get(MINUTE), int.class, options); - int second = converter.convert(map.get(SECOND), int.class, options); - int nano = converter.convert(map.get(NANO), int.class, options); - int offsetHour = converter.convert(map.get(OFFSET_HOUR), int.class, options); - int offsetMinute = converter.convert(map.get(OFFSET_MINUTE), int.class, options); + ConverterOptions options = converter.getOptions(); + int year = converter.convert(map.get(YEAR), int.class); + int month = converter.convert(map.get(MONTH), int.class); + int day = converter.convert(map.get(DAY), int.class); + int hour = converter.convert(map.get(HOUR), int.class); + int minute = converter.convert(map.get(MINUTE), int.class); + int second = converter.convert(map.get(SECOND), int.class); + int nano = converter.convert(map.get(NANO), int.class); + int offsetHour = converter.convert(map.get(OFFSET_HOUR), int.class); + int offsetMinute = converter.convert(map.get(OFFSET_MINUTE), int.class); ZoneOffset zoneOffset = ZoneOffset.ofHoursMinutes(offsetHour, offsetMinute); return OffsetDateTime.of(year, month, day, hour, minute, second, nano, zoneOffset); } else { - return fromValueForMultiKey(map, converter, options, OffsetDateTime.class, OFFSET_DATE_TIME_PARAMS); + return fromValueForMultiKey(map, converter, OffsetDateTime.class, OFFSET_DATE_TIME_PARAMS); } } - static LocalDateTime toLocalDateTime(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, LocalDateTime.class); + static LocalDateTime toLocalDateTime(Object from, Converter converter) { + return fromValue(from, converter, LocalDateTime.class); } - static ZonedDateTime toZonedDateTime(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, ZonedDateTime.class); + static ZonedDateTime toZonedDateTime(Object from, Converter converter) { + return fromValue(from, converter, ZonedDateTime.class); } - static Class toClass(Object from, Converter converter, ConverterOptions options) { - return fromValue(from, converter, options, Class.class); + static Class toClass(Object from, Converter converter) { + return fromValue(from, converter, Class.class); } private static final String[] DURATION_PARAMS = new String[] { SECONDS, NANOS }; - static Duration toDuration(Object from, Converter converter, ConverterOptions options) { + static Duration toDuration(Object from, Converter converter) { Map map = (Map) from; if (map.containsKey(SECONDS)) { - long sec = converter.convert(map.get(SECONDS), long.class, options); - long nanos = converter.convert(map.get(NANOS), long.class, options); + ConverterOptions options = converter.getOptions(); + long sec = converter.convert(map.get(SECONDS), long.class); + long nanos = converter.convert(map.get(NANOS), long.class); return Duration.ofSeconds(sec, nanos); } else { - return fromValueForMultiKey(from, converter, options, Duration.class, DURATION_PARAMS); + return fromValueForMultiKey(from, converter, Duration.class, DURATION_PARAMS); } } private static final String[] INSTANT_PARAMS = new String[] { SECONDS, NANOS }; - static Instant toInstant(Object from, Converter converter, ConverterOptions options) { + static Instant toInstant(Object from, Converter converter) { Map map = (Map) from; if (map.containsKey(SECONDS)) { - long sec = converter.convert(map.get(SECONDS), long.class, options); - long nanos = converter.convert(map.get(NANOS), long.class, options); + ConverterOptions options = converter.getOptions(); + long sec = converter.convert(map.get(SECONDS), long.class); + long nanos = converter.convert(map.get(NANOS), long.class); return Instant.ofEpochSecond(sec, nanos); } else { - return fromValueForMultiKey(from, converter, options, Instant.class, INSTANT_PARAMS); + return fromValueForMultiKey(from, converter, Instant.class, INSTANT_PARAMS); } } private static final String[] MONTH_DAY_PARAMS = new String[] { MONTH, DAY }; - static MonthDay toMonthDay(Object from, Converter converter, ConverterOptions options) { + static MonthDay toMonthDay(Object from, Converter converter) { Map map = (Map) from; if (map.containsKey(MONTH) && map.containsKey(DAY)) { - int month = converter.convert(map.get(MONTH), int.class, options); - int day = converter.convert(map.get(DAY), int.class, options); + ConverterOptions options = converter.getOptions(); + int month = converter.convert(map.get(MONTH), int.class); + int day = converter.convert(map.get(DAY), int.class); return MonthDay.of(month, day); } else { - return fromValueForMultiKey(from, converter, options, MonthDay.class, MONTH_DAY_PARAMS); + return fromValueForMultiKey(from, converter, MonthDay.class, MONTH_DAY_PARAMS); } } private static final String[] YEAR_MONTH_PARAMS = new String[] { YEAR, MONTH }; - static YearMonth toYearMonth(Object from, Converter converter, ConverterOptions options) { + static YearMonth toYearMonth(Object from, Converter converter) { Map map = (Map) from; if (map.containsKey(YEAR) && map.containsKey(MONTH)) { - int year = converter.convert(map.get(YEAR), int.class, options); - int month = converter.convert(map.get(MONTH), int.class, options); + ConverterOptions options = converter.getOptions(); + int year = converter.convert(map.get(YEAR), int.class); + int month = converter.convert(map.get(MONTH), int.class); return YearMonth.of(year, month); } else { - return fromValueForMultiKey(from, converter, options, YearMonth.class, YEAR_MONTH_PARAMS); + return fromValueForMultiKey(from, converter, YearMonth.class, YEAR_MONTH_PARAMS); } } private static final String[] PERIOD_PARAMS = new String[] { YEARS, MONTHS, DAYS }; - static Period toPeriod(Object from, Converter converter, ConverterOptions options) { + static Period toPeriod(Object from, Converter converter) { Map map = (Map) from; if (map.containsKey(YEARS) && map.containsKey(MONTHS) && map.containsKey(DAYS)) { - int years = converter.convert(map.get(YEARS), int.class, options); - int months = converter.convert(map.get(MONTHS), int.class, options); - int days = converter.convert(map.get(DAYS), int.class, options); + ConverterOptions options = converter.getOptions(); + int years = converter.convert(map.get(YEARS), int.class); + int months = converter.convert(map.get(MONTHS), int.class); + int days = converter.convert(map.get(DAYS), int.class); return Period.of(years, months, days); } else { - return fromValueForMultiKey(from, converter, options, Period.class, PERIOD_PARAMS); + return fromValueForMultiKey(from, converter, Period.class, PERIOD_PARAMS); } } - static ZoneId toZoneId(Object from, Converter converter, ConverterOptions options) { + static ZoneId toZoneId(Object from, Converter converter) { Map map = (Map) from; if (map.containsKey(ZONE)) { - ZoneId zoneId = converter.convert(map.get(ZONE), ZoneId.class, options); + ConverterOptions options = converter.getOptions(); + ZoneId zoneId = converter.convert(map.get(ZONE), ZoneId.class); return zoneId; } else { - return fromSingleKey(from, converter, options, ZONE, ZoneId.class); + return fromSingleKey(from, converter, ZONE, ZoneId.class); } } private static final String[] ZONE_OFFSET_PARAMS = new String[] { HOURS, MINUTES, SECONDS }; - static ZoneOffset toZoneOffset(Object from, Converter converter, ConverterOptions options) { + static ZoneOffset toZoneOffset(Object from, Converter converter) { Map map = (Map) from; if (map.containsKey(HOURS)) { - int hours = converter.convert(map.get(HOURS), int.class, options); - int minutes = converter.convert(map.get(MINUTES), int.class, options); // optional - int seconds = converter.convert(map.get(SECONDS), int.class, options); // optional + ConverterOptions options = converter.getOptions(); + int hours = converter.convert(map.get(HOURS), int.class); + int minutes = converter.convert(map.get(MINUTES), int.class); // optional + int seconds = converter.convert(map.get(SECONDS), int.class); // optional return ZoneOffset.ofHoursMinutesSeconds(hours, minutes, seconds); } else { - return fromValueForMultiKey(from, converter, options, ZoneOffset.class, ZONE_OFFSET_PARAMS); + return fromValueForMultiKey(from, converter, ZoneOffset.class, ZONE_OFFSET_PARAMS); } } - static Year toYear(Object from, Converter converter, ConverterOptions options) { - return fromSingleKey(from, converter, options, YEAR, Year.class); + static Year toYear(Object from, Converter converter) { + return fromSingleKey(from, converter, YEAR, Year.class); } - static Map initMap(Object from, Converter converter, ConverterOptions options) { + static Map initMap(Object from, Converter converter) { Map map = new CompactLinkedMap<>(); map.put(V, from); return map; @@ -368,47 +383,46 @@ static Year toYear(Object from, Converter converter, ConverterOptions options) { * @param type of object to convert the value. * @return type if it exists, else returns what is in V or VALUE */ - private static T fromSingleKey(final Object from, final Converter converter, final ConverterOptions options, final String key, final Class type) { - validateParams(converter, options, type); + private static T fromSingleKey(final Object from, final Converter converter, final String key, final Class type) { + validateParams(converter, type); Map map = asMap(from); if (map.containsKey(key)) { - return converter.convert(map.get(key), type, options); + return converter.convert(map.get(key), type); } - return extractValue(map, converter, options, type, key); + return extractValue(map, converter, type, key); } - private static T fromValueForMultiKey(Object from, Converter converter, ConverterOptions options, Class type, String[] keys) { - validateParams(converter, options, type); + private static T fromValueForMultiKey(Object from, Converter converter, Class type, String[] keys) { + validateParams(converter, type); - return extractValue(asMap(from), converter, options, type, keys); + return extractValue(asMap(from), converter, type, keys); } - private static T fromValue(Object from, Converter converter, ConverterOptions options, Class type) { - validateParams(converter, options, type); + private static T fromValue(Object from, Converter converter, Class type) { + validateParams(converter, type); - return extractValue(asMap(from), converter, options, type); + return extractValue(asMap(from), converter, type); } - private static T extractValue(Map map, Converter converter, ConverterOptions options, Class type, String...keys) { + private static T extractValue(Map map, Converter converter, Class type, String...keys) { if (map.containsKey(V)) { - return converter.convert(map.get(V), type, options); + return converter.convert(map.get(V), type); } if (map.containsKey(VALUE)) { - return converter.convert(map.get(VALUE), type, options); + return converter.convert(map.get(VALUE), type); } String keyText = ArrayUtilities.isEmpty(keys) ? "" : "[" + String.join(", ", keys) + "], "; throw new IllegalArgumentException(String.format(KEY_VALUE_ERROR_MESSAGE, Converter.getShortName(type), keyText)); } - private static void validateParams(Converter converter, ConverterOptions options, Class type) { + private static void validateParams(Converter converter, Class type) { Convention.throwIfNull(type, "type cannot be null"); Convention.throwIfNull(converter, "converter cannot be null"); - Convention.throwIfNull(options, "options cannot be null"); } private static Map asMap(Object o) { @@ -416,7 +430,7 @@ private static void validateParams(Converter converter, ConverterOptions opt return (Map)o; } - static Map toMap(Object from, Converter converter, ConverterOptions options) { + static Map toMap(Object from, Converter converter) { Map source = (Map) from; Map copy = new LinkedHashMap<>(source); return copy; diff --git a/src/main/java/com/cedarsoftware/util/convert/MonthDayConversions.java b/src/main/java/com/cedarsoftware/util/convert/MonthDayConversions.java index 8ca29b2f..9639a56a 100644 --- a/src/main/java/com/cedarsoftware/util/convert/MonthDayConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/MonthDayConversions.java @@ -22,11 +22,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class MonthDayConversions { +final class MonthDayConversions { private MonthDayConversions() {} - static Map toMap(Object from, Converter converter, ConverterOptions options) { + static Map toMap(Object from, Converter converter) { MonthDay monthDay = (MonthDay) from; Map target = new CompactLinkedMap<>(); target.put("day", monthDay.getDayOfMonth()); diff --git a/src/main/java/com/cedarsoftware/util/convert/NumberConversions.java b/src/main/java/com/cedarsoftware/util/convert/NumberConversions.java index ce8f578d..55527f06 100644 --- a/src/main/java/com/cedarsoftware/util/convert/NumberConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/NumberConversions.java @@ -35,59 +35,50 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class NumberConversions { - +final class NumberConversions { private NumberConversions() {} - static byte toByte(Object from, Converter converter, ConverterOptions options) { + static byte toByte(Object from, Converter converter) { return ((Number)from).byteValue(); } - static Byte toByteZero(Object from, Converter converter, ConverterOptions options) { + static Byte toByteZero(Object from, Converter converter) { return CommonValues.BYTE_ZERO; } - static short toShort(Object from, Converter converter, ConverterOptions options) { + static short toShort(Object from, Converter converter) { return ((Number)from).shortValue(); } - static Short toShortZero(Object from, Converter converter, ConverterOptions options) { + static Short toShortZero(Object from, Converter converter) { return CommonValues.SHORT_ZERO; } - static int toInt(Object from, Converter converter, ConverterOptions options) { + static int toInt(Object from, Converter converter) { return ((Number)from).intValue(); } - static Integer toIntZero(Object from, Converter converter, ConverterOptions options) { + static Integer toIntZero(Object from, Converter converter) { return CommonValues.INTEGER_ZERO; } - static long toLong(Object from, Converter converter, ConverterOptions options) { - return toLong(from); - } - - static long toLong(Object from) { + static long toLong(Object from, Converter converter) { return ((Number) from).longValue(); } - - static int toInt(Object from) { - return ((Number)from).intValue(); - } - - static Long toLongZero(Object from, Converter converter, ConverterOptions options) { + + static Long toLongZero(Object from, Converter converter) { return CommonValues.LONG_ZERO; } - static float toFloat(Object from, Converter converter, ConverterOptions options) { + static float toFloat(Object from, Converter converter) { return ((Number) from).floatValue(); } - static Float toFloatZero(Object from, Converter converter, ConverterOptions options) { + static Float toFloatZero(Object from, Converter converter) { return CommonValues.FLOAT_ZERO; } - static String floatToString(Object from, Converter converter, ConverterOptions option) { + static String floatToString(Object from, Converter converter) { float x = (float) from; if (x == 0f) { return "0"; @@ -95,19 +86,15 @@ static String floatToString(Object from, Converter converter, ConverterOptions o return from.toString(); } - static double toDouble(Object from, Converter converter, ConverterOptions options) { - return toDouble(from); - } - - static double toDouble(Object from) { + static double toDouble(Object from, Converter converter) { return ((Number) from).doubleValue(); } - static Double toDoubleZero(Object from, Converter converter, ConverterOptions options) { + static Double toDoubleZero(Object from, Converter converter) { return CommonValues.DOUBLE_ZERO; } - static String doubleToString(Object from, Converter converter, ConverterOptions option) { + static String doubleToString(Object from, Converter converter) { double x = (double) from; if (x == 0d) { return "0"; @@ -115,72 +102,73 @@ static String doubleToString(Object from, Converter converter, ConverterOptions return from.toString(); } - static BigDecimal integerTypeToBigDecimal(Object from, Converter converter, ConverterOptions options) { - return BigDecimal.valueOf(toLong(from)); + static BigDecimal integerTypeToBigDecimal(Object from, Converter converter) { + return BigDecimal.valueOf(toLong(from, converter)); } - static BigInteger integerTypeToBigInteger(Object from, Converter converter, ConverterOptions options) { - return BigInteger.valueOf(toLong(from)); + + static BigInteger integerTypeToBigInteger(Object from, Converter converter) { + return BigInteger.valueOf(toLong(from, converter)); } - static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) { - return new AtomicLong(toLong(from)); + static AtomicLong toAtomicLong(Object from, Converter converter) { + return new AtomicLong(toLong(from, converter)); } - static AtomicInteger toAtomicInteger(Object from, Converter converter, ConverterOptions options) { - return new AtomicInteger(toInt(from)); + static AtomicInteger toAtomicInteger(Object from, Converter converter) { + return new AtomicInteger(toInt(from, converter)); } - static BigDecimal bigIntegerToBigDecimal(Object from, Converter converter, ConverterOptions options) { + static BigDecimal bigIntegerToBigDecimal(Object from, Converter converter) { return new BigDecimal((BigInteger)from); } - static BigInteger bigDecimalToBigInteger(Object from, Converter converter, ConverterOptions options) { + static BigInteger bigDecimalToBigInteger(Object from, Converter converter) { return ((BigDecimal)from).toBigInteger(); } - static String bigDecimalToString(Object from, Converter converter, ConverterOptions options) { + static String bigDecimalToString(Object from, Converter converter) { return ((BigDecimal) from).stripTrailingZeros().toPlainString(); } - static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) { + static BigDecimal toBigDecimal(Object from, Converter converter) { return new BigDecimal(StringUtilities.trimToEmpty(from.toString())); } - static AtomicBoolean toAtomicBoolean(Object from, Converter converter, ConverterOptions options) { - return new AtomicBoolean(toLong(from) != 0); + static AtomicBoolean toAtomicBoolean(Object from, Converter converter) { + return new AtomicBoolean(toLong(from, converter) != 0); } - static BigDecimal floatingPointToBigDecimal(Object from, Converter converter, ConverterOptions options) { - return BigDecimal.valueOf(toDouble(from)); + static BigDecimal floatingPointToBigDecimal(Object from, Converter converter) { + return BigDecimal.valueOf(toDouble(from, converter)); } - static BigInteger floatingPointToBigInteger(Object from, Converter converter, ConverterOptions options) { - double d = toDouble(from); + static BigInteger floatingPointToBigInteger(Object from, Converter converter) { + double d = toDouble(from, converter); String s = String.format("%.0f", (d > 0.0) ? Math.floor(d) : Math.ceil(d)); return new BigInteger(s); } - static boolean isIntTypeNotZero(Object from, Converter converter, ConverterOptions options) { - return toLong(from) != 0; + static boolean isIntTypeNotZero(Object from, Converter converter) { + return toLong(from, converter) != 0; } - static boolean isFloatTypeNotZero(Object from, Converter converter, ConverterOptions options) { - return toDouble(from) != 0; + static boolean isFloatTypeNotZero(Object from, Converter converter) { + return toDouble(from, converter) != 0; } - static boolean isBigIntegerNotZero(Object from, Converter converter, ConverterOptions options) { + static boolean isBigIntegerNotZero(Object from, Converter converter) { return ((BigInteger)from).compareTo(BigInteger.ZERO) != 0; } - static boolean isBigDecimalNotZero(Object from, Converter converter, ConverterOptions options) { + static boolean isBigDecimalNotZero(Object from, Converter converter) { return ((BigDecimal)from).compareTo(BigDecimal.ZERO) != 0; } - static BigInteger toBigInteger(Object from, Converter converter, ConverterOptions options) { + static BigInteger toBigInteger(Object from, Converter converter) { return new BigInteger(StringUtilities.trimToEmpty(from.toString())); } - static UUID bigIntegerToUUID(Object from, Converter converter, ConverterOptions options) { + static UUID bigIntegerToUUID(Object from, Converter converter) { BigInteger bigInteger = (BigInteger) from; BigInteger mask = BigInteger.valueOf(Long.MAX_VALUE); long mostSignificantBits = bigInteger.shiftRight(64).and(mask).longValue(); @@ -188,7 +176,7 @@ static UUID bigIntegerToUUID(Object from, Converter converter, ConverterOptions return new UUID(mostSignificantBits, leastSignificantBits); } - static UUID bigDecimalToUUID(Object from, Converter converter, ConverterOptions options) { + static UUID bigDecimalToUUID(Object from, Converter converter) { BigInteger bigInt = ((BigDecimal) from).toBigInteger(); long mostSigBits = bigInt.shiftRight(64).longValue(); long leastSigBits = bigInt.and(new BigInteger("FFFFFFFFFFFFFFFF", 16)).longValue(); @@ -196,74 +184,57 @@ static UUID bigDecimalToUUID(Object from, Converter converter, ConverterOptions } /** - * @param from Number instance to convert to char. + * @param from - object that is a number to be converted to char + * @param converter - instance of converter mappings to use. * @return char that best represents the Number. The result will always be a value between * 0 and Character.MAX_VALUE. * @throws IllegalArgumentException if the value exceeds the range of a char. */ - static char toCharacter(Object from) { - long value = toLong(from); + static char toCharacter(Object from, Converter converter) { + long value = toLong(from, converter); if (value >= 0 && value <= Character.MAX_VALUE) { return (char) value; } - throw new IllegalArgumentException("Value: " + value + " out of range to be converted to character."); + throw new IllegalArgumentException("Value '" + value + "' out of range to be converted to character."); } - /** - * @param from - object that is a number to be converted to char - * @param converter - instance of converter mappings to use. - * @param options - optional conversion options, not used here. - * @return char that best represents the Number. The result will always be a value between - * 0 and Character.MAX_VALUE. - * @throws IllegalArgumentException if the value exceeds the range of a char. - */ - static char toCharacter(Object from, Converter converter, ConverterOptions options) { - return toCharacter(from); - } - - static Date toDate(Object from, Converter converter, ConverterOptions options) { - return new Date(toLong(from)); + static Date toDate(Object from, Converter converter) { + return new Date(toLong(from, converter)); } - - static Instant toInstant(Object from) { return Instant.ofEpochMilli(toLong(from)); } - - static Instant toInstant(Object from, Converter converter, ConverterOptions options) { - return toInstant(from); - } - - static java.sql.Date toSqlDate(Object from, Converter converter, ConverterOptions options) { - return new java.sql.Date(toLong(from)); + + static Instant toInstant(Object from, Converter converter) { + return Instant.ofEpochMilli(toLong(from, converter)); } - static Timestamp toTimestamp(Object from, Converter converter, ConverterOptions options) { - return new Timestamp(toLong(from)); + static java.sql.Date toSqlDate(Object from, Converter converter) { + return new java.sql.Date(toLong(from, converter)); } - static Calendar toCalendar(Object from, Converter converter, ConverterOptions options) { - return CalendarConversions.create(toLong(from), options); + static Timestamp toTimestamp(Object from, Converter converter) { + return new Timestamp(toLong(from, converter)); } - static LocalDate toLocalDate(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalDate(); + static Calendar toCalendar(Object from, Converter converter) { + return CalendarConversions.create(toLong(from, converter), converter); } - static LocalDateTime toLocalDateTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalDateTime(); + static LocalDate toLocalDate(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalDate(); } - static LocalTime toLocalTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options).toLocalTime(); + static LocalDateTime toLocalDateTime(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalDateTime(); } - static ZonedDateTime toZonedDateTime(Object from, ConverterOptions options) { - return toInstant(from).atZone(options.getZoneId()); + static LocalTime toLocalTime(Object from, Converter converter) { + return toZonedDateTime(from, converter).toLocalTime(); } - - static ZonedDateTime toZonedDateTime(Object from, Converter converter, ConverterOptions options) { - return toZonedDateTime(from, options); + + static ZonedDateTime toZonedDateTime(Object from, Converter converter) { + return toInstant(from, converter).atZone(converter.getOptions().getZoneId()); } - static Year toYear(Object from, Converter converter, ConverterOptions options) { + static Year toYear(Object from, Converter converter) { if (from instanceof Byte) { throw new IllegalArgumentException("Cannot convert Byte to Year, not enough precision."); } diff --git a/src/main/java/com/cedarsoftware/util/convert/OffsetDateTimeConversions.java b/src/main/java/com/cedarsoftware/util/convert/OffsetDateTimeConversions.java index e3b68cec..b7ea90ae 100644 --- a/src/main/java/com/cedarsoftware/util/convert/OffsetDateTimeConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/OffsetDateTimeConversions.java @@ -31,78 +31,70 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public class OffsetDateTimeConversions { +final class OffsetDateTimeConversions { private OffsetDateTimeConversions() {} - static OffsetDateTime toDifferentZone(Object from, ConverterOptions options) { + static OffsetDateTime toDifferentZone(Object from, Converter converter) { OffsetDateTime offsetDateTime = (OffsetDateTime) from; - return offsetDateTime.toInstant().atZone(options.getZoneId()).toOffsetDateTime(); + return offsetDateTime.toInstant().atZone(converter.getOptions().getZoneId()).toOffsetDateTime(); } - static Instant toInstant(Object from) { + static Instant toInstant(Object from, Converter converter) { return ((OffsetDateTime)from).toInstant(); } - static long toLong(Object from) { - return toInstant(from).toEpochMilli(); + static long toLong(Object from, Converter converter) { + return toInstant(from, converter).toEpochMilli(); } - - static long toLong(Object from, Converter converter, ConverterOptions options) { - return toLong(from); - } - - static Instant toInstant(Object from, Converter converter, ConverterOptions options) { - return toInstant(from); - } - - static LocalDateTime toLocalDateTime(Object from, Converter converter, ConverterOptions options) { - return toDifferentZone(from, options).toLocalDateTime(); + + static LocalDateTime toLocalDateTime(Object from, Converter converter) { + return toDifferentZone(from, converter).toLocalDateTime(); } - static LocalDate toLocalDate(Object from, Converter converter, ConverterOptions options) { - return toDifferentZone(from, options).toLocalDate(); + static LocalDate toLocalDate(Object from, Converter converter) { + return toDifferentZone(from, converter).toLocalDate(); } - static LocalTime toLocalTime(Object from, Converter converter, ConverterOptions options) { - return toDifferentZone(from, options).toLocalTime(); + static LocalTime toLocalTime(Object from, Converter converter) { + return toDifferentZone(from, converter).toLocalTime(); } - static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) { - return new AtomicLong(toLong(from)); + static AtomicLong toAtomicLong(Object from, Converter converter) { + return new AtomicLong(toLong(from, converter)); } - static Timestamp toTimestamp(Object from, Converter converter, ConverterOptions options) { - return new Timestamp(toLong(from)); + static Timestamp toTimestamp(Object from, Converter converter) { + return new Timestamp(toLong(from, converter)); } - static Calendar toCalendar(Object from, Converter converter, ConverterOptions options) { - Calendar calendar = Calendar.getInstance(options.getTimeZone()); - calendar.setTimeInMillis(toLong(from)); + static Calendar toCalendar(Object from, Converter converter) { + Calendar calendar = Calendar.getInstance(converter.getOptions().getTimeZone()); + calendar.setTimeInMillis(toLong(from, converter)); return calendar; } - static java.sql.Date toSqlDate(Object from, Converter converter, ConverterOptions options) { - return new java.sql.Date(toLong(from)); + static java.sql.Date toSqlDate(Object from, Converter converter) { + return new java.sql.Date(toLong(from, converter)); } - static Date toDate(Object from, Converter converter, ConverterOptions options) { - return new Date(toLong(from)); + static Date toDate(Object from, Converter converter) { + return new Date(toLong(from, converter)); } - static BigInteger toBigInteger(Object from, Converter converter, ConverterOptions options) { - return BigInteger.valueOf(toLong(from)); + static BigInteger toBigInteger(Object from, Converter converter) { + return BigInteger.valueOf(toLong(from, converter)); } - static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) { - return BigDecimal.valueOf(toLong(from)); + static BigDecimal toBigDecimal(Object from, Converter converter) { + return BigDecimal.valueOf(toLong(from, converter)); } - static OffsetTime toOffsetTime(Object from, Converter converter, ConverterOptions options) { + static OffsetTime toOffsetTime(Object from, Converter converter) { OffsetDateTime dateTime = (OffsetDateTime) from; return dateTime.toOffsetTime(); } - static String toString(Object from, Converter converter, ConverterOptions options) { + static String toString(Object from, Converter converter) { OffsetDateTime offsetDateTime = (OffsetDateTime) from; return offsetDateTime.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); } diff --git a/src/main/java/com/cedarsoftware/util/convert/OffsetTimeConversions.java b/src/main/java/com/cedarsoftware/util/convert/OffsetTimeConversions.java index 5f1ad0e6..ce204f58 100644 --- a/src/main/java/com/cedarsoftware/util/convert/OffsetTimeConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/OffsetTimeConversions.java @@ -20,10 +20,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public class OffsetTimeConversions { +final class OffsetTimeConversions { private OffsetTimeConversions() {} - static String toString(Object from, Converter converter, ConverterOptions options) { + static String toString(Object from, Converter converter) { OffsetTime offsetTime = (OffsetTime) from; return offsetTime.format(DateTimeFormatter.ISO_OFFSET_TIME); } diff --git a/src/main/java/com/cedarsoftware/util/convert/PeriodConversions.java b/src/main/java/com/cedarsoftware/util/convert/PeriodConversions.java index 167895e7..bde879fa 100644 --- a/src/main/java/com/cedarsoftware/util/convert/PeriodConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/PeriodConversions.java @@ -22,11 +22,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class PeriodConversions { +final class PeriodConversions { private PeriodConversions() {} - static Map toMap(Object from, Converter converter, ConverterOptions options) { + static Map toMap(Object from, Converter converter) { Period period = (Period) from; Map target = new CompactLinkedMap<>(); target.put("years", period.getYears()); diff --git a/src/main/java/com/cedarsoftware/util/convert/StringConversions.java b/src/main/java/com/cedarsoftware/util/convert/StringConversions.java index e9c10b48..e7991697 100644 --- a/src/main/java/com/cedarsoftware/util/convert/StringConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/StringConversions.java @@ -1,9 +1,5 @@ package com.cedarsoftware.util.convert; -import com.cedarsoftware.util.ClassUtilities; -import com.cedarsoftware.util.DateUtilities; -import com.cedarsoftware.util.StringUtilities; - import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; @@ -37,6 +33,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import com.cedarsoftware.util.ClassUtilities; +import com.cedarsoftware.util.DateUtilities; +import com.cedarsoftware.util.StringUtilities; + import static com.cedarsoftware.util.ArrayUtilities.EMPTY_BYTE_ARRAY; import static com.cedarsoftware.util.ArrayUtilities.EMPTY_CHAR_ARRAY; @@ -57,7 +57,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class StringConversions { +final class StringConversions { private static final BigDecimal bigDecimalMinByte = BigDecimal.valueOf(Byte.MIN_VALUE); private static final BigDecimal bigDecimalMaxByte = BigDecimal.valueOf(Byte.MAX_VALUE); private static final BigDecimal bigDecimalMinShort = BigDecimal.valueOf(Short.MIN_VALUE); @@ -74,11 +74,8 @@ static String asString(Object from) { return from == null ? null : from.toString(); } - static Byte toByte(Object from, Converter converter, ConverterOptions options) { - return toByte(asString(from)); - } - - private static Byte toByte(String s) { + static Byte toByte(Object from, Converter converter) { + String s = asString(from); if (s.isEmpty()) { return CommonValues.BYTE_ZERO; } @@ -93,12 +90,8 @@ private static Byte toByte(String s) { } } - static Short toShort(Object from, Converter converter, ConverterOptions options) { - return toShort(from); - } - - private static Short toShort(Object o) { - String str = StringUtilities.trimToEmpty((String)o); + static Short toShort(Object from, Converter converter) { + String str = StringUtilities.trimToEmpty((String) from); if (str.isEmpty()) { return CommonValues.SHORT_ZERO; } @@ -107,17 +100,13 @@ private static Short toShort(Object o) { } catch (NumberFormatException e) { Long value = toLong(str, bigDecimalMinShort, bigDecimalMaxShort); if (value == null) { - throw new IllegalArgumentException("Value '" + o + "' not parseable as a short value or outside " + Short.MIN_VALUE + " to " + Short.MAX_VALUE); + throw new IllegalArgumentException("Value '" + from + "' not parseable as a short value or outside " + Short.MIN_VALUE + " to " + Short.MAX_VALUE); } return value.shortValue(); } } - static Integer toInt(Object from, Converter converter, ConverterOptions options) { - return toInt(from); - } - - private static Integer toInt(Object from) { + static Integer toInt(Object from, Converter converter) { String str = StringUtilities.trimToEmpty(asString(from)); if (str.isEmpty()) { return CommonValues.INTEGER_ZERO; @@ -133,11 +122,7 @@ private static Integer toInt(Object from) { } } - static Long toLong(Object from, Converter converter, ConverterOptions options) { - return toLong(from); - } - - private static Long toLong(Object from) { + static Long toLong(Object from, Converter converter) { String str = StringUtilities.trimToEmpty(asString(from)); if (str.isEmpty()) { return CommonValues.LONG_ZERO; @@ -167,7 +152,7 @@ private static Long toLong(String s, BigDecimal low, BigDecimal high) { } } - static Float toFloat(Object from, Converter converter, ConverterOptions options) { + static Float toFloat(Object from, Converter converter) { String str = StringUtilities.trimToEmpty(asString(from)); if (str.isEmpty()) { return CommonValues.FLOAT_ZERO; @@ -179,7 +164,7 @@ static Float toFloat(Object from, Converter converter, ConverterOptions options) } } - static Double toDouble(Object from, Converter converter, ConverterOptions options) { + static Double toDouble(Object from, Converter converter) { String str = StringUtilities.trimToEmpty(asString(from)); if (str.isEmpty()) { return CommonValues.DOUBLE_ZERO; @@ -191,20 +176,21 @@ static Double toDouble(Object from, Converter converter, ConverterOptions option } } - static AtomicBoolean toAtomicBoolean(Object from, Converter converter, ConverterOptions options) { - return new AtomicBoolean(toBoolean(asString(from))); + static AtomicBoolean toAtomicBoolean(Object from, Converter converter) { + return new AtomicBoolean(toBoolean(asString(from), converter)); } - static AtomicInteger toAtomicInteger(Object from, Converter converter, ConverterOptions options) { - return new AtomicInteger(toInt(from)); + static AtomicInteger toAtomicInteger(Object from, Converter converter) { + return new AtomicInteger(toInt(from, converter)); } - static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) { - return new AtomicLong(toLong(from)); + static AtomicLong toAtomicLong(Object from, Converter converter) { + return new AtomicLong(toLong(from, converter)); } - - private static Boolean toBoolean(String from) { - String str = StringUtilities.trimToEmpty(from); + + static Boolean toBoolean(Object from, Converter converter) { + String from1 = asString(from); + String str = StringUtilities.trimToEmpty(from1); if (str.isEmpty()) { return false; } @@ -217,11 +203,7 @@ private static Boolean toBoolean(String from) { return "true".equalsIgnoreCase(str) || "t".equalsIgnoreCase(str) || "1".equals(str) || "y".equalsIgnoreCase(str); } - static Boolean toBoolean(Object from, Converter converter, ConverterOptions options) { - return toBoolean(asString(from)); - } - - static char toCharacter(Object from, Converter converter, ConverterOptions options) { + static char toCharacter(Object from, Converter converter) { String str = StringUtilities.trimToNull(asString(from)); if (str == null) { return CommonValues.CHARACTER_ZERO; @@ -233,7 +215,7 @@ static char toCharacter(Object from, Converter converter, ConverterOptions optio return (char) Integer.parseInt(str.trim()); } - static BigInteger toBigInteger(Object from, Converter converter, ConverterOptions options) { + static BigInteger toBigInteger(Object from, Converter converter) { String str = StringUtilities.trimToNull(asString(from)); if (str == null) { return BigInteger.ZERO; @@ -246,7 +228,7 @@ static BigInteger toBigInteger(Object from, Converter converter, ConverterOption } } - static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) { + static BigDecimal toBigDecimal(Object from, Converter converter) { String str = StringUtilities.trimToEmpty(asString(from)); if (str.isEmpty()) { return BigDecimal.ZERO; @@ -258,28 +240,28 @@ static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOption } } - static String enumToString(Object from, Converter converter, ConverterOptions options) { + static String enumToString(Object from, Converter converter) { return ((Enum) from).name(); } - static UUID toUUID(Object from, Converter converter, ConverterOptions options) { + static UUID toUUID(Object from, Converter converter) { return UUID.fromString(((String) from).trim()); } - static Duration toDuration(Object from, Converter converter, ConverterOptions options) { + static Duration toDuration(Object from, Converter converter) { return Duration.parse((String) from); } - static Class toClass(Object from, Converter converter, ConverterOptions options) { + static Class toClass(Object from, Converter converter) { String str = ((String) from).trim(); - Class clazz = ClassUtilities.forName(str, options.getClassLoader()); + Class clazz = ClassUtilities.forName(str, converter.getOptions().getClassLoader()); if (clazz != null) { return clazz; } throw new IllegalArgumentException("Cannot convert String '" + str + "' to class. Class not found."); } - static MonthDay toMonthDay(Object from, Converter converter, ConverterOptions options) { + static MonthDay toMonthDay(Object from, Converter converter) { String monthDay = (String) from; try { return MonthDay.parse(monthDay); @@ -293,7 +275,7 @@ static MonthDay toMonthDay(Object from, Converter converter, ConverterOptions op } else { try { - ZonedDateTime zdt = DateUtilities.parseDate(monthDay, options.getZoneId(), true); + ZonedDateTime zdt = DateUtilities.parseDate(monthDay, converter.getOptions().getZoneId(), true); return MonthDay.of(zdt.getMonthValue(), zdt.getDayOfMonth()); } catch (Exception ex) { @@ -303,14 +285,14 @@ static MonthDay toMonthDay(Object from, Converter converter, ConverterOptions op } } - static YearMonth toYearMonth(Object from, Converter converter, ConverterOptions options) { + static YearMonth toYearMonth(Object from, Converter converter) { String yearMonth = (String) from; try { return YearMonth.parse(yearMonth); } catch (DateTimeParseException e) { try { - ZonedDateTime zdt = DateUtilities.parseDate(yearMonth, options.getZoneId(), true); + ZonedDateTime zdt = DateUtilities.parseDate(yearMonth, converter.getOptions().getZoneId(), true); return YearMonth.of(zdt.getYear(), zdt.getMonthValue()); } catch (Exception ex) { @@ -319,7 +301,7 @@ static YearMonth toYearMonth(Object from, Converter converter, ConverterOptions } } - static Period toPeriod(Object from, Converter converter, ConverterOptions options) { + static Period toPeriod(Object from, Converter converter) { String period = (String) from; try { return Period.parse(period); @@ -329,34 +311,34 @@ static Period toPeriod(Object from, Converter converter, ConverterOptions option } } - static Date toDate(Object from, Converter converter, ConverterOptions options) { - Instant instant = toInstant(from, options); + static Date toDate(Object from, Converter converter) { + Instant instant = toInstant(from, converter); return instant == null ? null : Date.from(instant); } - static java.sql.Date toSqlDate(Object from, Converter converter, ConverterOptions options) { - Instant instant = toInstant(from, options); + static java.sql.Date toSqlDate(Object from, Converter converter) { + Instant instant = toInstant(from, converter); return instant == null ? null : new java.sql.Date(instant.toEpochMilli()); } - static Timestamp toTimestamp(Object from, Converter converter, ConverterOptions options) { - Instant instant = toInstant(from, options); + static Timestamp toTimestamp(Object from, Converter converter) { + Instant instant = toInstant(from, converter); return instant == null ? null : new Timestamp(instant.toEpochMilli()); } - static Calendar toCalendar(Object from, Converter converter, ConverterOptions options) { - return parseDate(from, options).map(GregorianCalendar::from).orElse(null); + static Calendar toCalendar(Object from, Converter converter) { + return parseDate(from, converter).map(GregorianCalendar::from).orElse(null); } - static LocalDate toLocalDate(Object from, Converter converter, ConverterOptions options) { - return parseDate(from, options).map(ZonedDateTime::toLocalDate).orElse(null); + static LocalDate toLocalDate(Object from, Converter converter) { + return parseDate(from, converter).map(ZonedDateTime::toLocalDate).orElse(null); } - static LocalDateTime toLocalDateTime(Object from, Converter converter, ConverterOptions options) { - return parseDate(from, options).map(ZonedDateTime::toLocalDateTime).orElse(null); + static LocalDateTime toLocalDateTime(Object from, Converter converter) { + return parseDate(from, converter).map(ZonedDateTime::toLocalDateTime).orElse(null); } - static LocalTime toLocalTime(Object from, Converter converter, ConverterOptions options) { + static LocalTime toLocalTime(Object from, Converter converter) { String str = StringUtilities.trimToNull(asString(from)); if (str == null) { return null; @@ -365,18 +347,18 @@ static LocalTime toLocalTime(Object from, Converter converter, ConverterOptions try { return LocalTime.parse(str); } catch (Exception e) { - return parseDate(str, options).map(ZonedDateTime::toLocalTime).orElse(null); + return parseDate(str, converter).map(ZonedDateTime::toLocalTime).orElse(null); } } - private static Optional parseDate(Object from, ConverterOptions options) { + private static Optional parseDate(Object from, Converter converter) { String str = StringUtilities.trimToNull(asString(from)); if (str == null) { return Optional.empty(); } - ZonedDateTime zonedDateTime = DateUtilities.parseDate(str, options.getZoneId(), true); + ZonedDateTime zonedDateTime = DateUtilities.parseDate(str, converter.getOptions().getZoneId(), true); if (zonedDateTime == null) { return Optional.empty(); @@ -386,11 +368,11 @@ private static Optional parseDate(Object from, ConverterOptions o } - static ZonedDateTime toZonedDateTime(Object from, Converter converter, ConverterOptions options) { - return parseDate(from, options).orElse(null); + static ZonedDateTime toZonedDateTime(Object from, Converter converter) { + return parseDate(from, converter).orElse(null); } - static ZoneId toZoneId(Object from, Converter converter, ConverterOptions options) { + static ZoneId toZoneId(Object from, Converter converter) { String s = StringUtilities.trimToNull(asString(from)); if (s == null) { return null; @@ -403,7 +385,7 @@ static ZoneId toZoneId(Object from, Converter converter, ConverterOptions option } } - static ZoneOffset toZoneOffset(Object from, Converter converter, ConverterOptions options) { + static ZoneOffset toZoneOffset(Object from, Converter converter) { String s = StringUtilities.trimToNull(asString(from)); if (s == null) { return null; @@ -416,11 +398,11 @@ static ZoneOffset toZoneOffset(Object from, Converter converter, ConverterOption } } - static OffsetDateTime toOffsetDateTime(Object from, Converter converter, ConverterOptions options) { - return parseDate(from, options).map(ZonedDateTime::toOffsetDateTime).orElse(null); + static OffsetDateTime toOffsetDateTime(Object from, Converter converter) { + return parseDate(from, converter).map(ZonedDateTime::toOffsetDateTime).orElse(null); } - static OffsetTime toOffsetTime(Object from, Converter converter, ConverterOptions options) { + static OffsetTime toOffsetTime(Object from, Converter converter) { String s = StringUtilities.trimToNull(asString(from)); if (s == null) { return null; @@ -429,7 +411,7 @@ static OffsetTime toOffsetTime(Object from, Converter converter, ConverterOption try { return OffsetTime.parse(s, DateTimeFormatter.ISO_OFFSET_TIME); } catch (Exception e) { - OffsetDateTime dateTime = toOffsetDateTime(from, converter, options); + OffsetDateTime dateTime = toOffsetDateTime(from, converter); if (dateTime == null) { return null; } @@ -437,15 +419,11 @@ static OffsetTime toOffsetTime(Object from, Converter converter, ConverterOption } } - private static Instant toInstant(Object from, ConverterOptions options) { - return parseDate(from, options).map(ZonedDateTime::toInstant).orElse(null); - } - - static Instant toInstant(Object from, Converter converter, ConverterOptions options) { - return toInstant(from, options); + static Instant toInstant(Object from, Converter converter) { + return parseDate(from, converter).map(ZonedDateTime::toInstant).orElse(null); } - static char[] toCharArray(Object from, Converter converter, ConverterOptions options) { + static char[] toCharArray(Object from, Converter converter) { String s = asString(from); if (s == null || s.isEmpty()) { @@ -455,41 +433,37 @@ static char[] toCharArray(Object from, Converter converter, ConverterOptions opt return s.toCharArray(); } - static CharBuffer toCharBuffer(Object from, Converter converter, ConverterOptions options) { + static CharBuffer toCharBuffer(Object from, Converter converter) { return CharBuffer.wrap(asString(from)); } - static byte[] toByteArray(Object from, ConverterOptions options) { + static byte[] toByteArray(Object from, Converter converter) { String s = asString(from); if (s == null || s.isEmpty()) { return EMPTY_BYTE_ARRAY; } - return s.getBytes(options.getCharset()); + return s.getBytes(converter.getOptions().getCharset()); } - - static byte[] toByteArray(Object from, Converter converter, ConverterOptions options) { - return toByteArray(from, options); - } - - static ByteBuffer toByteBuffer(Object from, Converter converter, ConverterOptions options) { - return ByteBuffer.wrap(toByteArray(from, options)); + + static ByteBuffer toByteBuffer(Object from, Converter converter) { + return ByteBuffer.wrap(toByteArray(from, converter)); } - static String toString(Object from, Converter converter, ConverterOptions options) { + static String toString(Object from, Converter converter) { return from == null ? null : from.toString(); } - static StringBuffer toStringBuffer(Object from, Converter converter, ConverterOptions options) { + static StringBuffer toStringBuffer(Object from, Converter converter) { return from == null ? null : new StringBuffer(from.toString()); } - static StringBuilder toStringBuilder(Object from, Converter converter, ConverterOptions options) { + static StringBuilder toStringBuilder(Object from, Converter converter) { return from == null ? null : new StringBuilder(from.toString()); } - static Year toYear(Object from, Converter converter, ConverterOptions options) { + static Year toYear(Object from, Converter converter) { String s = StringUtilities.trimToNull(asString(from)); if (s == null) { return null; @@ -500,7 +474,7 @@ static Year toYear(Object from, Converter converter, ConverterOptions options) { } catch (NumberFormatException e) { try { - ZonedDateTime zdt = DateUtilities.parseDate(s, options.getZoneId(), true); + ZonedDateTime zdt = DateUtilities.parseDate(s, converter.getOptions().getZoneId(), true); return Year.of(zdt.getYear()); } catch (Exception ex) { diff --git a/src/main/java/com/cedarsoftware/util/convert/UUIDConversions.java b/src/main/java/com/cedarsoftware/util/convert/UUIDConversions.java index 9e37998d..060bc284 100644 --- a/src/main/java/com/cedarsoftware/util/convert/UUIDConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/UUIDConversions.java @@ -21,12 +21,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class UUIDConversions { +final class UUIDConversions { private UUIDConversions() { } - static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) { + static BigDecimal toBigDecimal(Object from, Converter converter) { UUID uuid = (UUID) from; BigInteger mostSignificant = BigInteger.valueOf(uuid.getMostSignificantBits()); BigInteger leastSignificant = BigInteger.valueOf(uuid.getLeastSignificantBits()); @@ -34,7 +34,7 @@ static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOption return new BigDecimal(mostSignificant.shiftLeft(64).add(leastSignificant)); } - static BigInteger toBigInteger(Object from, Converter converter, ConverterOptions options) { + static BigInteger toBigInteger(Object from, Converter converter) { UUID uuid = (UUID) from; BigInteger mostSignificant = BigInteger.valueOf(uuid.getMostSignificantBits()); BigInteger leastSignificant = BigInteger.valueOf(uuid.getLeastSignificantBits()); diff --git a/src/main/java/com/cedarsoftware/util/convert/VoidConversions.java b/src/main/java/com/cedarsoftware/util/convert/VoidConversions.java index 0717e8f4..d23967ce 100644 --- a/src/main/java/com/cedarsoftware/util/convert/VoidConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/VoidConversions.java @@ -17,18 +17,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class VoidConversions { +final class VoidConversions { private VoidConversions() { } - static Object toNull(Object from, Converter converter, ConverterOptions options) { + static Object toNull(Object from, Converter converter) { return null; } - static Boolean toBoolean(Object from, Converter converter, ConverterOptions options) { + static Boolean toBoolean(Object from, Converter converter) { return Boolean.FALSE; } - static Character toChar(Object from, Converter converter, ConverterOptions options) { + static Character toChar(Object from, Converter converter) { return Character.MIN_VALUE; } } diff --git a/src/main/java/com/cedarsoftware/util/convert/YearConversions.java b/src/main/java/com/cedarsoftware/util/convert/YearConversions.java index 1a76cfe4..a76155d4 100644 --- a/src/main/java/com/cedarsoftware/util/convert/YearConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/YearConversions.java @@ -7,58 +7,71 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -public class YearConversions { +/** + * @author Kenny Partlow (kpartlow@gmail.com) + *
+ * Copyright (c) Cedar Software LLC + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * License + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +final class YearConversions { private YearConversions() {} - static int toInt(Object from) { - return ((Year)from).getValue(); + static long toLong(Object from, Converter converter) { + return toInt(from, converter); } - static long toLong(Object from, Converter converter, ConverterOptions options) { - return toInt(from); + static short toShort(Object from, Converter converter) { + return (short) toInt(from, converter); } - static short toShort(Object from, Converter converter, ConverterOptions options) { - return (short) toInt(from); + static int toInt(Object from, Converter converter) { + return ((Year) from).getValue(); } - static int toInt(Object from, Converter converter, ConverterOptions options) { - return toInt(from); + static AtomicInteger toAtomicInteger(Object from, Converter converter) { + return new AtomicInteger(toInt(from, converter)); } - static AtomicInteger toAtomicInteger(Object from, Converter converter, ConverterOptions options) { - return new AtomicInteger(toInt(from)); + static AtomicLong toAtomicLong(Object from, Converter converter) { + return new AtomicLong(toInt(from, converter)); } - static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) { - return new AtomicLong(toInt(from)); + static double toDouble(Object from, Converter converter) { + return toInt(from, converter); } - static double toDouble(Object from, Converter converter, ConverterOptions options) { - return toInt(from); + static float toFloat(Object from, Converter converter) { + return toInt(from, converter); } - static float toFloat(Object from, Converter converter, ConverterOptions options) { - return toInt(from); + static boolean toBoolean(Object from, Converter converter) { + return toInt(from, converter) == 0; } - static boolean toBoolean(Object from, Converter converter, ConverterOptions options) { - return toInt(from) == 0; + static AtomicBoolean toAtomicBoolean(Object from, Converter converter) { + return new AtomicBoolean(toInt(from, converter) == 0); } - static AtomicBoolean toAtomicBoolean(Object from, Converter converter, ConverterOptions options) { - return new AtomicBoolean(toInt(from) == 0); + static BigInteger toBigInteger(Object from, Converter converter) { + return BigInteger.valueOf(toInt(from, converter)); } - static BigInteger toBigInteger(Object from, Converter converter, ConverterOptions options) { - return BigInteger.valueOf(toInt(from)); + static BigDecimal toBigDecimal(Object from, Converter converter) { + return BigDecimal.valueOf(toInt(from, converter)); } - static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) { - return BigDecimal.valueOf(toInt(from)); - } - - static String toString(Object from, Converter converter, ConverterOptions options) { + static String toString(Object from, Converter converter) { return ((Year)from).toString(); } } diff --git a/src/main/java/com/cedarsoftware/util/convert/YearMonthConversions.java b/src/main/java/com/cedarsoftware/util/convert/YearMonthConversions.java index 6ce23cce..6f1a8e06 100644 --- a/src/main/java/com/cedarsoftware/util/convert/YearMonthConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/YearMonthConversions.java @@ -22,11 +22,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class YearMonthConversions { +final class YearMonthConversions { private YearMonthConversions() {} - static Map toMap(Object from, Converter converter, ConverterOptions options) { + static Map toMap(Object from, Converter converter) { YearMonth yearMonth = (YearMonth) from; Map target = new CompactLinkedMap<>(); target.put("year", yearMonth.getYear()); diff --git a/src/main/java/com/cedarsoftware/util/convert/ZoneIdConversions.java b/src/main/java/com/cedarsoftware/util/convert/ZoneIdConversions.java index ef2bb81c..222756a7 100644 --- a/src/main/java/com/cedarsoftware/util/convert/ZoneIdConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/ZoneIdConversions.java @@ -22,11 +22,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class ZoneIdConversions { +final class ZoneIdConversions { private ZoneIdConversions() {} - static Map toMap(Object from, Converter converter, ConverterOptions options) { + static Map toMap(Object from, Converter converter) { ZoneId zoneID = (ZoneId) from; Map target = new CompactLinkedMap<>(); target.put("zone", zoneID.toString()); diff --git a/src/main/java/com/cedarsoftware/util/convert/ZoneOffsetConversions.java b/src/main/java/com/cedarsoftware/util/convert/ZoneOffsetConversions.java index 4c7c2e0d..bdd2233d 100644 --- a/src/main/java/com/cedarsoftware/util/convert/ZoneOffsetConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/ZoneOffsetConversions.java @@ -22,11 +22,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class ZoneOffsetConversions { +final class ZoneOffsetConversions { private ZoneOffsetConversions() {} - static Map toMap(Object from, Converter converter, ConverterOptions options) { + static Map toMap(Object from, Converter converter) { ZoneOffset offset = (ZoneOffset) from; Map target = new CompactLinkedMap<>(); int totalSeconds = offset.getTotalSeconds(); diff --git a/src/main/java/com/cedarsoftware/util/convert/ZonedDateTimeConversions.java b/src/main/java/com/cedarsoftware/util/convert/ZonedDateTimeConversions.java index e891a56f..e584b1c0 100644 --- a/src/main/java/com/cedarsoftware/util/convert/ZonedDateTimeConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/ZonedDateTimeConversions.java @@ -31,74 +31,64 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -public final class ZonedDateTimeConversions { +final class ZonedDateTimeConversions { private ZonedDateTimeConversions() {} - static ZonedDateTime toDifferentZone(Object from, ConverterOptions options) { - return ((ZonedDateTime)from).withZoneSameInstant(options.getZoneId()); + static ZonedDateTime toDifferentZone(Object from, Converter converter) { + return ((ZonedDateTime)from).withZoneSameInstant(converter.getOptions().getZoneId()); } - - static Instant toInstant(Object from) { - return ((ZonedDateTime)from).toInstant(); - } - - static long toLong(Object from) { - return toInstant(from).toEpochMilli(); + + static long toLong(Object from, Converter converter) { + return toInstant(from, converter).toEpochMilli(); } - static long toLong(Object from, Converter converter, ConverterOptions options) { - return toLong(from); + static Instant toInstant(Object from, Converter converter) { + return ((ZonedDateTime) from).toInstant(); } - static Instant toInstant(Object from, Converter converter, ConverterOptions options) { - return toInstant(from); + static LocalDateTime toLocalDateTime(Object from, Converter converter) { + return toDifferentZone(from, converter).toLocalDateTime(); } - static LocalDateTime toLocalDateTime(Object from, Converter converter, ConverterOptions options) { - return toDifferentZone(from, options).toLocalDateTime(); + static LocalDate toLocalDate(Object from, Converter converter) { + return toDifferentZone(from, converter).toLocalDate(); } - static LocalDate toLocalDate(Object from, Converter converter, ConverterOptions options) { - return toDifferentZone(from, options).toLocalDate(); + static LocalTime toLocalTime(Object from, Converter converter) { + return toDifferentZone(from, converter).toLocalTime(); } - static LocalTime toLocalTime(Object from, Converter converter, ConverterOptions options) { - return toDifferentZone(from, options).toLocalTime(); + static AtomicLong toAtomicLong(Object from, Converter converter) { + return new AtomicLong(toLong(from, converter)); } - static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) { - return new AtomicLong(toLong(from)); + static Timestamp toTimestamp(Object from, Converter converter) { + return new Timestamp(toLong(from, converter)); } - static Timestamp toTimestamp(Object from, Converter converter, ConverterOptions options) { - return new Timestamp(toLong(from)); - } - - static Calendar toCalendar(Object from, Converter converter, ConverterOptions options) { + static Calendar toCalendar(Object from, Converter converter) { return GregorianCalendar.from((ZonedDateTime) from); - //return CalendarConversions.create(toLong(from), options); } - static java.sql.Date toSqlDate(Object from, Converter converter, ConverterOptions options) { - return new java.sql.Date(toLong(from)); + static java.sql.Date toSqlDate(Object from, Converter converter) { + return new java.sql.Date(toLong(from, converter)); } - static Date toDate(Object from, Converter converter, ConverterOptions options) { - return new Date(toLong(from)); + static Date toDate(Object from, Converter converter) { + return new Date(toLong(from, converter)); } - static BigInteger toBigInteger(Object from, Converter converter, ConverterOptions options) { - return BigInteger.valueOf(toLong(from)); + static BigInteger toBigInteger(Object from, Converter converter) { + return BigInteger.valueOf(toLong(from, converter)); } - static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) { - return BigDecimal.valueOf(toLong(from)); + static BigDecimal toBigDecimal(Object from, Converter converter) { + return BigDecimal.valueOf(toLong(from, converter)); } - static String toString(Object from, Converter converter, ConverterOptions options) { + static String toString(Object from, Converter converter) { ZonedDateTime zonedDateTime = (ZonedDateTime) from; return zonedDateTime.format(DateTimeFormatter.ISO_DATE_TIME); } - } diff --git a/src/test/java/com/cedarsoftware/util/convert/AtomicBooleanConversionsTests.java b/src/test/java/com/cedarsoftware/util/convert/AtomicBooleanConversionsTests.java index e574e5b2..517be299 100644 --- a/src/test/java/com/cedarsoftware/util/convert/AtomicBooleanConversionsTests.java +++ b/src/test/java/com/cedarsoftware/util/convert/AtomicBooleanConversionsTests.java @@ -2,7 +2,6 @@ import java.math.BigDecimal; import java.math.BigInteger; - import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; @@ -26,7 +25,7 @@ private static Stream toByteParams() { @ParameterizedTest @MethodSource("toByteParams") void testToByte(boolean value, Byte expected) { - Byte actual = AtomicBooleanConversions.toByte(new AtomicBoolean(value), null, null); + Byte actual = AtomicBooleanConversions.toByte(new AtomicBoolean(value), null); assertThat(actual).isSameAs(expected); } @@ -40,7 +39,7 @@ private static Stream toShortParams() { @ParameterizedTest @MethodSource("toShortParams") void testToShort(boolean value, Short expected) { - Short actual = AtomicBooleanConversions.toShort(new AtomicBoolean(value), null, null); + Short actual = AtomicBooleanConversions.toShort(new AtomicBoolean(value), null); assertThat(actual).isSameAs(expected); } @@ -54,7 +53,7 @@ private static Stream toIntegerParams() { @ParameterizedTest @MethodSource("toIntegerParams") void testToInteger(boolean value, Integer expected) { - Integer actual = AtomicBooleanConversions.toInteger(new AtomicBoolean(value), null, null); + Integer actual = AtomicBooleanConversions.toInteger(new AtomicBoolean(value), null); assertThat(actual).isSameAs(expected); } @@ -68,7 +67,7 @@ private static Stream toLongParams() { @ParameterizedTest @MethodSource("toLongParams") void testToLong(boolean value, long expected) { - long actual = AtomicBooleanConversions.toLong(new AtomicBoolean(value), null, null); + long actual = AtomicBooleanConversions.toLong(new AtomicBoolean(value), null); assertThat(actual).isSameAs(expected); } @@ -82,7 +81,7 @@ private static Stream toFloatParams() { @ParameterizedTest @MethodSource("toFloatParams") void testToFloat(boolean value, Float expected) { - Float actual = AtomicBooleanConversions.toFloat(new AtomicBoolean(value), null, null); + Float actual = AtomicBooleanConversions.toFloat(new AtomicBoolean(value), null); assertThat(actual).isSameAs(expected); } @@ -97,7 +96,7 @@ private static Stream toDoubleParams() { @ParameterizedTest @MethodSource("toDoubleParams") void testToDouble(boolean value, Double expected) { - Double actual = AtomicBooleanConversions.toDouble(new AtomicBoolean(value), null, null); + Double actual = AtomicBooleanConversions.toDouble(new AtomicBoolean(value), null); assertThat(actual).isSameAs(expected); } @@ -112,7 +111,7 @@ private static Stream toBooleanParams() { @ParameterizedTest @MethodSource("toBooleanParams") void testToBoolean(boolean value) { - boolean actual = AtomicBooleanConversions.toBoolean(new AtomicBoolean(value), null, null); + boolean actual = AtomicBooleanConversions.toBoolean(new AtomicBoolean(value), null); assertThat(actual).isSameAs(Boolean.valueOf(value)); } @@ -120,7 +119,7 @@ void testToBoolean(boolean value) { @MethodSource("toIntegerParams") void testToAtomicInteger(boolean value, int integer) { AtomicInteger expected = new AtomicInteger(integer);; - AtomicInteger actual = AtomicBooleanConversions.toAtomicInteger(new AtomicBoolean(value), null, null); + AtomicInteger actual = AtomicBooleanConversions.toAtomicInteger(new AtomicBoolean(value), null); assertThat(actual.get()).isEqualTo(expected.get()); } @@ -128,42 +127,10 @@ void testToAtomicInteger(boolean value, int integer) { @MethodSource("toLongParams") void testToAtomicLong(boolean value, long expectedLong) { AtomicLong expected = new AtomicLong(expectedLong); - AtomicLong actual = AtomicBooleanConversions.toAtomicLong(new AtomicBoolean(value), null, null); + AtomicLong actual = AtomicBooleanConversions.toAtomicLong(new AtomicBoolean(value), null); assertThat(actual.get()).isEqualTo(expected.get()); } - private static Stream toCharacter_withDefaultParams() { - return Stream.of( - Arguments.of(true, CommonValues.CHARACTER_ONE), - Arguments.of(false, CommonValues.CHARACTER_ZERO) - ); - } - - @ParameterizedTest - @MethodSource("toCharacter_withDefaultParams") - void testToCharacter_withDefaultParams(boolean value, char expected) { - ConverterOptions options = createConvertOptions(CommonValues.CHARACTER_ONE, CommonValues.CHARACTER_ZERO); - Character actual = AtomicBooleanConversions.toCharacter(new AtomicBoolean(value), null, options); - assertThat(actual).isSameAs(expected); - } - - private static Stream toCharacterCustomParams() { - return Stream.of( - Arguments.of('T', 'F', true, 'T'), - Arguments.of('T', 'F', false, 'F') - ); - } - - - @ParameterizedTest - @MethodSource("toCharacterCustomParams") - void testToCharacter_withCustomChars(char trueChar, char falseChar, boolean value, char expected) { - ConverterOptions options = createConvertOptions(trueChar, falseChar); - char actual = BooleanConversions.toCharacter(value, null, options); - assertThat(actual).isEqualTo(expected); - } - - private static Stream toBigDecimalParams() { return Stream.of( Arguments.of(true, BigDecimal.ONE), @@ -174,7 +141,7 @@ private static Stream toBigDecimalParams() { @ParameterizedTest @MethodSource("toBigDecimalParams") void testToBigDecimal(boolean value, BigDecimal expected) { - BigDecimal actual = AtomicBooleanConversions.toBigDecimal(new AtomicBoolean(value), null, null); + BigDecimal actual = AtomicBooleanConversions.toBigDecimal(new AtomicBoolean(value), null); assertThat(actual).isSameAs(expected); } @@ -187,7 +154,7 @@ private static Stream toBigIntegerParams() { @ParameterizedTest @MethodSource("toBigIntegerParams") void testToBigDecimal(boolean value, BigInteger expected) { - BigInteger actual = AtomicBooleanConversions.toBigInteger(new AtomicBoolean(value), null, null); + BigInteger actual = AtomicBooleanConversions.toBigInteger(new AtomicBoolean(value), null); assertThat(actual).isSameAs(expected); } diff --git a/src/test/java/com/cedarsoftware/util/convert/BooleanConversionsTests.java b/src/test/java/com/cedarsoftware/util/convert/BooleanConversionsTests.java index 29d64c1b..c5b14635 100644 --- a/src/test/java/com/cedarsoftware/util/convert/BooleanConversionsTests.java +++ b/src/test/java/com/cedarsoftware/util/convert/BooleanConversionsTests.java @@ -1,10 +1,7 @@ package com.cedarsoftware.util.convert; -import java.lang.reflect.Constructor; -import java.lang.reflect.Modifier; import java.math.BigDecimal; import java.math.BigInteger; - import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; @@ -17,8 +14,6 @@ import org.junit.jupiter.params.provider.MethodSource; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; class BooleanConversionsTests { @@ -40,7 +35,7 @@ private static Stream toByteParams() { @ParameterizedTest @MethodSource("toByteParams") void testToByte(boolean value, Byte expected) { - Byte actual = BooleanConversions.toByte(value, null, null); + Byte actual = BooleanConversions.toByte(value, null); assertThat(actual).isSameAs(expected); } @@ -54,7 +49,7 @@ private static Stream toShortParams() { @ParameterizedTest @MethodSource("toShortParams") void testToShort(boolean value, Short expected) { - Short actual = BooleanConversions.toShort(value, null, null); + Short actual = BooleanConversions.toShort(value, null); assertThat(actual).isSameAs(expected); } @@ -68,7 +63,7 @@ private static Stream toIntegerParams() { @ParameterizedTest @MethodSource("toIntegerParams") void testToInteger(boolean value, Integer expected) { - Integer actual = BooleanConversions.toInteger(value, null, null); + Integer actual = BooleanConversions.toInteger(value, null); assertThat(actual).isSameAs(expected); } @@ -82,7 +77,7 @@ private static Stream toLongParams() { @ParameterizedTest @MethodSource("toLongParams") void testToLong(boolean value, long expected) { - long actual = BooleanConversions.toLong(value, null, null); + long actual = BooleanConversions.toLong(value, null); assertThat(actual).isSameAs(expected); } @@ -96,7 +91,7 @@ private static Stream toFloatParams() { @ParameterizedTest @MethodSource("toFloatParams") void testToFloat(boolean value, Float expected) { - Float actual = BooleanConversions.toFloat(value, null, null); + Float actual = BooleanConversions.toFloat(value, null); assertThat(actual).isSameAs(expected); } @@ -111,7 +106,7 @@ private static Stream toDoubleParams() { @ParameterizedTest @MethodSource("toDoubleParams") void testToDouble(boolean value, Double expected) { - Double actual = BooleanConversions.toDouble(value, null, null); + Double actual = BooleanConversions.toDouble(value, null); assertThat(actual).isSameAs(expected); } @@ -127,7 +122,7 @@ private static Stream toBooleanParams() { @MethodSource("toBooleanParams") void testToAtomicBoolean(boolean value) { AtomicBoolean expected = new AtomicBoolean(value);; - AtomicBoolean actual = BooleanConversions.toAtomicBoolean(value, null, null); + AtomicBoolean actual = BooleanConversions.toAtomicBoolean(value, null); assertThat(actual.get()).isEqualTo(expected.get()); } @@ -135,7 +130,7 @@ void testToAtomicBoolean(boolean value) { @MethodSource("toIntegerParams") void testToAtomicInteger(boolean value, int integer) { AtomicInteger expected = new AtomicInteger(integer);; - AtomicInteger actual = BooleanConversions.toAtomicInteger(value, null, null); + AtomicInteger actual = BooleanConversions.toAtomicInteger(value, null); assertThat(actual.get()).isEqualTo(expected.get()); } @@ -143,42 +138,10 @@ void testToAtomicInteger(boolean value, int integer) { @MethodSource("toLongParams") void testToAtomicLong(boolean value, long expectedLong) { AtomicLong expected = new AtomicLong(expectedLong); - AtomicLong actual = BooleanConversions.toAtomicLong(value, null, null); + AtomicLong actual = BooleanConversions.toAtomicLong(value, null); assertThat(actual.get()).isEqualTo(expected.get()); } - - private static Stream toCharacterDefaultParams() { - return Stream.of( - Arguments.of(true, CommonValues.CHARACTER_ONE), - Arguments.of(false, CommonValues.CHARACTER_ZERO) - ); - } - - - @ParameterizedTest - @MethodSource("toCharacterDefaultParams") - void testToCharacter_withDefaultChars(boolean value, char expected) { - ConverterOptions options = createConvertOptions(CommonValues.CHARACTER_ONE, CommonValues.CHARACTER_ZERO); - Character actual = BooleanConversions.toCharacter(value, null, options); - assertThat(actual).isSameAs(expected); - } - - private static Stream toCharacterCustomParams() { - return Stream.of( - Arguments.of('T', 'F', true, 'T'), - Arguments.of('T', 'F', false, 'F') - ); - } - - - @ParameterizedTest - @MethodSource("toCharacterCustomParams") - void testToCharacter_withCustomChars(char trueChar, char falseChar, boolean value, char expected) { - ConverterOptions options = createConvertOptions(trueChar, falseChar); - char actual = BooleanConversions.toCharacter(value, null, options); - assertThat(actual).isEqualTo(expected); - } - + private static Stream toBigDecimalParams() { return Stream.of( Arguments.of(true, BigDecimal.ONE), @@ -189,7 +152,7 @@ private static Stream toBigDecimalParams() { @ParameterizedTest @MethodSource("toBigDecimalParams") void testToBigDecimal(boolean value, BigDecimal expected) { - BigDecimal actual = BooleanConversions.toBigDecimal(value, null, null); + BigDecimal actual = BooleanConversions.toBigDecimal(value, null); assertThat(actual).isSameAs(expected); } @@ -202,7 +165,7 @@ private static Stream toBigIntegerParams() { @ParameterizedTest @MethodSource("toBigIntegerParams") void testToBigDecimal(boolean value, BigInteger expected) { - BigInteger actual = BooleanConversions.toBigInteger(value, null, null); + BigInteger actual = BooleanConversions.toBigInteger(value, null); assertThat(actual).isSameAs(expected); } diff --git a/src/test/java/com/cedarsoftware/util/convert/ConverterEverythingTest.java b/src/test/java/com/cedarsoftware/util/convert/ConverterEverythingTest.java index 687180b0..f090639a 100644 --- a/src/test/java/com/cedarsoftware/util/convert/ConverterEverythingTest.java +++ b/src/test/java/com/cedarsoftware/util/convert/ConverterEverythingTest.java @@ -734,17 +734,17 @@ void testConvert(String shortNameSource, String shortNameTarget, Object source, // if the source/target are the same Class, then ensure identity lambda is used. if (sourceClass.equals(targetClass)) { - assertSame(source, converter.convert(source, targetClass, options)); + assertSame(source, converter.convert(source, targetClass)); } if (target instanceof Throwable) { Throwable t = (Throwable) target; assertThatExceptionOfType(t.getClass()) - .isThrownBy(() -> converter.convert(source, targetClass, options)) + .isThrownBy(() -> converter.convert(source, targetClass)) .withMessageContaining(((Throwable) target).getMessage()); } else { // Assert values are equals - Object actual = converter.convert(source, targetClass, options); + Object actual = converter.convert(source, targetClass); assertEquals(target, actual); } } diff --git a/src/test/java/com/cedarsoftware/util/convert/ConverterTest.java b/src/test/java/com/cedarsoftware/util/convert/ConverterTest.java index 66bc995d..3c844a4c 100644 --- a/src/test/java/com/cedarsoftware/util/convert/ConverterTest.java +++ b/src/test/java/com/cedarsoftware/util/convert/ConverterTest.java @@ -1,15 +1,5 @@ package com.cedarsoftware.util.convert; -import com.cedarsoftware.util.DeepEquals; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.EmptySource; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.NullAndEmptySource; -import org.junit.jupiter.params.provider.NullSource; - import java.math.BigDecimal; import java.math.BigInteger; import java.nio.ByteBuffer; @@ -38,6 +28,16 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Stream; +import com.cedarsoftware.util.DeepEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.EmptySource; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.NullAndEmptySource; +import org.junit.jupiter.params.provider.NullSource; + import static com.cedarsoftware.util.ArrayUtilities.EMPTY_BYTE_ARRAY; import static com.cedarsoftware.util.ArrayUtilities.EMPTY_CHAR_ARRAY; import static com.cedarsoftware.util.Converter.zonedDateTimeToMillis; @@ -751,7 +751,8 @@ private static Stream dateStringInIsoZoneDateTime() { @ParameterizedTest @MethodSource("epochMilliWithZoneId") void testEpochMilliWithZoneId(String epochMilli, ZoneId zoneId) { - LocalDateTime localDateTime = this.converter.convert(epochMilli, LocalDateTime.class, createCustomZones(NEW_YORK)); + Converter converter = new Converter(createCustomZones(NEW_YORK)); + LocalDateTime localDateTime = converter.convert(epochMilli, LocalDateTime.class); assertThat(localDateTime) .hasYear(1999) @@ -766,7 +767,8 @@ void testEpochMilliWithZoneId(String epochMilli, ZoneId zoneId) { @MethodSource("dateStringNoZoneOffset") void testStringDateWithNoTimeZoneInformation(String date, ZoneId zoneId) { // times with zoneid passed in to convert to ZonedDateTime - ZonedDateTime zdt = this.converter.convert(date, ZonedDateTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + ZonedDateTime zdt = converter.convert(date, ZonedDateTime.class); // convert to local time NY ZonedDateTime nyTime = zdt.withZoneSameInstant(NEW_YORK); @@ -785,7 +787,8 @@ void testStringDateWithNoTimeZoneInformation(String date, ZoneId zoneId) { @MethodSource("dateStringInIsoOffsetDateTime") void testStringDateWithTimeZoneToLocalDateTime(String date) { // source is TOKYO, should be ignored when zone is provided on string. - ZonedDateTime zdt = this.converter.convert(date, ZonedDateTime.class, createCustomZones(IGNORED)); + Converter converter = new Converter(createCustomZones(IGNORED)); + ZonedDateTime zdt = converter.convert(date, ZonedDateTime.class); ZonedDateTime nyTime = zdt.withZoneSameInstant(NEW_YORK); @@ -803,7 +806,8 @@ void testStringDateWithTimeZoneToLocalDateTime(String date) { @MethodSource("dateStringInIsoOffsetDateTimeWithMillis") void testStringDateWithTimeZoneToLocalDateTimeIncludeMillis(String date) { // will come in with the zone from the string. - ZonedDateTime zdt = this.converter.convert(date, ZonedDateTime.class, createCustomZones(IGNORED)); + Converter converter = new Converter(createCustomZones(IGNORED)); + ZonedDateTime zdt = converter.convert(date, ZonedDateTime.class); // create zoned date time from the localDateTime from string, providing NEW_YORK as time zone. LocalDateTime localDateTime = zdt.withZoneSameInstant(NEW_YORK).toLocalDateTime(); @@ -822,7 +826,8 @@ void testStringDateWithTimeZoneToLocalDateTimeIncludeMillis(String date) { @MethodSource("dateStringInIsoZoneDateTime") void testStringDateWithTimeZoneToLocalDateTimeWithZone(String date) { // will come in with the zone from the string. - ZonedDateTime zdt = this.converter.convert(date, ZonedDateTime.class, createCustomZones(IGNORED)); + Converter converter = new Converter(createCustomZones(IGNORED)); + ZonedDateTime zdt = converter.convert(date, ZonedDateTime.class); // create localDateTime in NEW_YORK time. LocalDateTime localDateTime = zdt.withZoneSameInstant(NEW_YORK).toLocalDateTime(); @@ -878,7 +883,8 @@ void testCalendarToLocalDateTime(long epochMilli, ZoneId zoneId, LocalDateTime e Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(zoneId)); calendar.setTimeInMillis(epochMilli); - LocalDateTime localDateTime = this.converter.convert(calendar, LocalDateTime.class, createCustomZones(IGNORED)); + Converter converter = new Converter(createCustomZones(IGNORED)); + LocalDateTime localDateTime = converter.convert(calendar, LocalDateTime.class); assertThat(localDateTime).isEqualTo(expected); } @@ -890,7 +896,8 @@ void testCalendarToLocalDateTime_whenCalendarTimeZoneMatches(long epochMilli, Zo Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(zoneId)); calendar.setTimeInMillis(epochMilli); - LocalDateTime localDateTime = this.converter.convert(calendar, LocalDateTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDateTime localDateTime = converter.convert(calendar, LocalDateTime.class); assertThat(localDateTime).isEqualTo(expected); } @@ -901,7 +908,8 @@ void testCalendarToLocalDateTime_whenCalendarTimeZoneDoesNotMatch(long epochMill Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(zoneId)); calendar.setTimeInMillis(epochMilli); - LocalDateTime localDateTime = this.converter.convert(calendar, LocalDateTime.class, createCustomZones(IGNORED)); + Converter converter = new Converter(createCustomZones(IGNORED)); + LocalDateTime localDateTime = converter.convert(calendar, LocalDateTime.class); assertThat(localDateTime).isEqualTo(expected); } @@ -941,7 +949,8 @@ void testCalendar_toLocalDate(long epochMilli, ZoneId zoneId, LocalDate expected assertThat(calendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(expected.getDayOfMonth()); assertThat(calendar.getTimeInMillis()).isEqualTo(epochMilli); - LocalDate localDate = this.converter.convert(calendar, LocalDate.class, createCustomZones(IGNORED)); + Converter converter = new Converter(createCustomZones(IGNORED)); + LocalDate localDate = converter.convert(calendar, LocalDate.class); assertThat(localDate).isEqualTo(expected); } @@ -955,7 +964,8 @@ private static Stream localDateToLong() { @MethodSource("localDateToLong") void testConvertLocalDateToLong(long epochMilli, ZoneId zoneId, LocalDate expected) { - long intermediate = this.converter.convert(expected, long.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + long intermediate = converter.convert(expected, long.class); assertThat(intermediate).isEqualTo(epochMilli); } @@ -964,7 +974,8 @@ void testConvertLocalDateToLong(long epochMilli, ZoneId zoneId, LocalDate expect @MethodSource("localDateToLong") void testLocalDateToInstant(long epochMilli, ZoneId zoneId, LocalDate expected) { - Instant intermediate = this.converter.convert(expected, Instant.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + Instant intermediate = converter.convert(expected, Instant.class); assertThat(intermediate.toEpochMilli()).isEqualTo(epochMilli); } @@ -973,7 +984,8 @@ void testLocalDateToInstant(long epochMilli, ZoneId zoneId, LocalDate expected) @MethodSource("localDateToLong") void testLocalDateToDouble(long epochMilli, ZoneId zoneId, LocalDate expected) { - double intermediate = this.converter.convert(expected, double.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + double intermediate = converter.convert(expected, double.class); assertThat((long)intermediate).isEqualTo(epochMilli); } @@ -982,7 +994,8 @@ void testLocalDateToDouble(long epochMilli, ZoneId zoneId, LocalDate expected) { @MethodSource("localDateToLong") void testLocalDateToAtomicLong(long epochMilli, ZoneId zoneId, LocalDate expected) { - AtomicLong intermediate = this.converter.convert(expected, AtomicLong.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + AtomicLong intermediate = converter.convert(expected, AtomicLong.class); assertThat(intermediate.get()).isEqualTo(epochMilli); } @@ -991,7 +1004,8 @@ void testLocalDateToAtomicLong(long epochMilli, ZoneId zoneId, LocalDate expecte @MethodSource("localDateToLong") void testLocalDateToDate(long epochMilli, ZoneId zoneId, LocalDate expected) { - Date intermediate = this.converter.convert(expected,Date.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + Date intermediate = converter.convert(expected,Date.class); assertThat(intermediate.getTime()).isEqualTo(epochMilli); } @@ -999,41 +1013,47 @@ void testLocalDateToDate(long epochMilli, ZoneId zoneId, LocalDate expected) { @ParameterizedTest @MethodSource("localDateToLong") void testLocalDateSqlDate(long epochMilli, ZoneId zoneId, LocalDate expected) { - java.sql.Date intermediate = this.converter.convert(expected, java.sql.Date.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + java.sql.Date intermediate = converter.convert(expected, java.sql.Date.class); assertThat(intermediate.getTime()).isEqualTo(epochMilli); } @ParameterizedTest @MethodSource("localDateToLong") void testLocalDateTimestamp(long epochMilli, ZoneId zoneId, LocalDate expected) { - Timestamp intermediate = this.converter.convert(expected, Timestamp.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + Timestamp intermediate = converter.convert(expected, Timestamp.class); assertThat(intermediate.getTime()).isEqualTo(epochMilli); } @ParameterizedTest @MethodSource("localDateToLong") void testLocalDateZonedDateTime(long epochMilli, ZoneId zoneId, LocalDate expected) { - ZonedDateTime intermediate = this.converter.convert(expected, ZonedDateTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + ZonedDateTime intermediate = converter.convert(expected, ZonedDateTime.class); assertThat(intermediate.toInstant().toEpochMilli()).isEqualTo(epochMilli); } @ParameterizedTest @MethodSource("localDateToLong") void testLocalDateToBigInteger(long epochMilli, ZoneId zoneId, LocalDate expected) { - BigInteger intermediate = this.converter.convert(expected, BigInteger.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + BigInteger intermediate = converter.convert(expected, BigInteger.class); assertThat(intermediate.longValue()).isEqualTo(epochMilli); } @ParameterizedTest @MethodSource("localDateToLong") void testLocalDateToBigDecimal(long epochMilli, ZoneId zoneId, LocalDate expected) { - BigDecimal intermediate = this.converter.convert(expected, BigDecimal.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + BigDecimal intermediate = converter.convert(expected, BigDecimal.class); assertThat(intermediate.longValue()).isEqualTo(epochMilli); } @Test void testLocalDateToFloat() { - float intermediate = this.converter.convert(LD_MILLENNIUM_NY, float.class, createCustomZones(TOKYO)); + Converter converter = new Converter(createCustomZones(TOKYO)); + float intermediate = converter.convert(LD_MILLENNIUM_NY, float.class); assertThat((long)intermediate).isNotEqualTo(946616400000L); } @@ -1043,7 +1063,8 @@ void testZonedDateTimeToLocalDateTime(long epochMilli, ZoneId zoneId, LocalDateT { ZonedDateTime time = Instant.ofEpochMilli(epochMilli).atZone(zoneId); - LocalDateTime localDateTime = this.converter.convert(time, LocalDateTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDateTime localDateTime = converter.convert(time, LocalDateTime.class); assertThat(time.toInstant().toEpochMilli()).isEqualTo(epochMilli); assertThat(localDateTime).isEqualTo(expected); @@ -1056,7 +1077,8 @@ void testZonedDateTimeToLocalTime(long epochMilli, ZoneId zoneId, LocalDateTime { ZonedDateTime time = Instant.ofEpochMilli(epochMilli).atZone(zoneId); - LocalTime actual = this.converter.convert(time, LocalTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalTime actual = converter.convert(time, LocalTime.class); assertThat(actual).isEqualTo(expected.toLocalTime()); } @@ -1067,7 +1089,8 @@ void testZonedDateTimeToLocalDate(long epochMilli, ZoneId zoneId, LocalDateTime { ZonedDateTime time = Instant.ofEpochMilli(epochMilli).atZone(zoneId); - LocalDate actual = this.converter.convert(time, LocalDate.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDate actual = converter.convert(time, LocalDate.class); assertThat(actual).isEqualTo(expected.toLocalDate()); } @@ -1078,7 +1101,8 @@ void testZonedDateTimeToInstant(long epochMilli, ZoneId zoneId, LocalDateTime ex { ZonedDateTime time = Instant.ofEpochMilli(epochMilli).atZone(zoneId); - Instant actual = this.converter.convert(time, Instant.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + Instant actual = converter.convert(time, Instant.class); assertThat(actual).isEqualTo(time.toInstant()); } @@ -1089,7 +1113,8 @@ void testZonedDateTimeToCalendar(long epochMilli, ZoneId zoneId, LocalDateTime e { ZonedDateTime time = Instant.ofEpochMilli(epochMilli).atZone(zoneId); - Calendar actual = this.converter.convert(time, Calendar.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + Calendar actual = converter.convert(time, Calendar.class); assertThat(actual.getTime().getTime()).isEqualTo(time.toInstant().toEpochMilli()); assertThat(actual.getTimeZone()).isEqualTo(TimeZone.getTimeZone(zoneId)); @@ -1102,7 +1127,8 @@ void testZonedDateTimeToLong(long epochMilli, ZoneId zoneId, LocalDateTime local { ZonedDateTime time = ZonedDateTime.of(localDateTime, zoneId); - long instant = this.converter.convert(time, long.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + long instant = converter.convert(time, long.class); assertThat(instant).isEqualTo(epochMilli); } @@ -1112,7 +1138,8 @@ void testZonedDateTimeToLong(long epochMilli, ZoneId zoneId, LocalDateTime local @MethodSource("epochMillis_withLocalDateTimeInformation") void testLongToLocalDateTime(long epochMilli, ZoneId zoneId, LocalDateTime expected) { - LocalDateTime localDateTime = this.converter.convert(epochMilli, LocalDateTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDateTime localDateTime = converter.convert(epochMilli, LocalDateTime.class); assertThat(localDateTime).isEqualTo(expected); } @@ -1122,7 +1149,8 @@ void testAtomicLongToLocalDateTime(long epochMilli, ZoneId zoneId, LocalDateTime { AtomicLong time = new AtomicLong(epochMilli); - LocalDateTime localDateTime = this.converter.convert(time, LocalDateTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDateTime localDateTime = converter.convert(time, LocalDateTime.class); assertThat(localDateTime).isEqualTo(expected); } @@ -1130,7 +1158,8 @@ void testAtomicLongToLocalDateTime(long epochMilli, ZoneId zoneId, LocalDateTime @MethodSource("epochMillis_withLocalDateTimeInformation") void testLongToInstant(long epochMilli, ZoneId zoneId, LocalDateTime expected) { - Instant actual = this.converter.convert(epochMilli, Instant.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + Instant actual = converter.convert(epochMilli, Instant.class); assertThat(actual).isEqualTo(Instant.ofEpochMilli(epochMilli)); } @@ -1140,7 +1169,8 @@ void testBigIntegerToLocalDateTime(long epochMilli, ZoneId zoneId, LocalDateTime { BigInteger bi = BigInteger.valueOf(epochMilli); - LocalDateTime localDateTime = this.converter.convert(bi, LocalDateTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDateTime localDateTime = converter.convert(bi, LocalDateTime.class); assertThat(localDateTime).isEqualTo(expected); } @@ -1150,7 +1180,8 @@ void testBigDecimalToLocalDateTime(long epochMilli, ZoneId zoneId, LocalDateTime { BigDecimal bd = BigDecimal.valueOf(epochMilli); - LocalDateTime localDateTime = this.converter.convert(bd, LocalDateTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDateTime localDateTime = converter.convert(bd, LocalDateTime.class); assertThat(localDateTime).isEqualTo(expected); } @@ -1159,7 +1190,8 @@ void testBigDecimalToLocalDateTime(long epochMilli, ZoneId zoneId, LocalDateTime void testInstantToLocalDateTime(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Instant instant = Instant.ofEpochMilli(epochMilli); - LocalDateTime localDateTime = this.converter.convert(instant, LocalDateTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDateTime localDateTime = converter.convert(instant, LocalDateTime.class); assertThat(localDateTime).isEqualTo(expected); } @@ -1168,7 +1200,8 @@ void testInstantToLocalDateTime(long epochMilli, ZoneId zoneId, LocalDateTime ex void testDateToLocalDateTime(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Date date = new Date(epochMilli); - LocalDateTime localDateTime = this.converter.convert(date, LocalDateTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDateTime localDateTime = converter.convert(date, LocalDateTime.class); assertThat(localDateTime).isEqualTo(expected); } @@ -1177,7 +1210,8 @@ void testDateToLocalDateTime(long epochMilli, ZoneId zoneId, LocalDateTime expec void testDateToZonedDateTime(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Date date = new Date(epochMilli); - ZonedDateTime zonedDateTime = this.converter.convert(date, ZonedDateTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + ZonedDateTime zonedDateTime = converter.convert(date, ZonedDateTime.class); assertThat(zonedDateTime.toLocalDateTime()).isEqualTo(expected); } @@ -1186,7 +1220,8 @@ void testDateToZonedDateTime(long epochMilli, ZoneId zoneId, LocalDateTime expec void testInstantToZonedDateTime(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Instant date = Instant.ofEpochMilli(epochMilli); - ZonedDateTime zonedDateTime = this.converter.convert(date, ZonedDateTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + ZonedDateTime zonedDateTime = converter.convert(date, ZonedDateTime.class); assertThat(zonedDateTime.toInstant()).isEqualTo(date); } @@ -1195,17 +1230,18 @@ void testInstantToZonedDateTime(long epochMilli, ZoneId zoneId, LocalDateTime ex void testDateToInstant(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Date date = new Date(epochMilli); - Instant actual = this.converter.convert(date, Instant.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + Instant actual = converter.convert(date, Instant.class); assertThat(actual.toEpochMilli()).isEqualTo(epochMilli); } - - + @ParameterizedTest @MethodSource("epochMillis_withLocalDateTimeInformation") void testSqlDateToLocalDateTime(long epochMilli, ZoneId zoneId, LocalDateTime expected) { java.sql.Date date = new java.sql.Date(epochMilli); - LocalDateTime localDateTime = this.converter.convert(date, LocalDateTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDateTime localDateTime = converter.convert(date, LocalDateTime.class); assertThat(localDateTime).isEqualTo(expected); } @@ -1214,7 +1250,8 @@ void testSqlDateToLocalDateTime(long epochMilli, ZoneId zoneId, LocalDateTime ex void testInstantToLong(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Instant instant = Instant.ofEpochMilli(epochMilli); - long actual = this.converter.convert(instant, long.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + long actual = converter.convert(instant, long.class); assertThat(actual).isEqualTo(epochMilli); } @@ -1223,7 +1260,8 @@ void testInstantToLong(long epochMilli, ZoneId zoneId, LocalDateTime expected) void testInstantToAtomicLong(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Instant instant = Instant.ofEpochMilli(epochMilli); - AtomicLong actual = this.converter.convert(instant, AtomicLong.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + AtomicLong actual = converter.convert(instant, AtomicLong.class); assertThat(actual.get()).isEqualTo(epochMilli); } @@ -1232,7 +1270,8 @@ void testInstantToAtomicLong(long epochMilli, ZoneId zoneId, LocalDateTime expec void testInstantToFloat(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Instant instant = Instant.ofEpochMilli(epochMilli); - float actual = this.converter.convert(instant, float.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + float actual = converter.convert(instant, float.class); assertThat(actual).isEqualTo((float)epochMilli); } @@ -1241,7 +1280,8 @@ void testInstantToFloat(long epochMilli, ZoneId zoneId, LocalDateTime expected) void testInstantToDouble(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Instant instant = Instant.ofEpochMilli(epochMilli); - double actual = this.converter.convert(instant, double.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + double actual = converter.convert(instant, double.class); assertThat(actual).isEqualTo((double)epochMilli); } @@ -1250,7 +1290,8 @@ void testInstantToDouble(long epochMilli, ZoneId zoneId, LocalDateTime expected) void testInstantToTimestamp(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Instant instant = Instant.ofEpochMilli(epochMilli); - Timestamp actual = this.converter.convert(instant, Timestamp.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + Timestamp actual = converter.convert(instant, Timestamp.class); assertThat(actual.getTime()).isEqualTo(epochMilli); } @@ -1259,7 +1300,8 @@ void testInstantToTimestamp(long epochMilli, ZoneId zoneId, LocalDateTime expect void testInstantToDate(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Instant instant = Instant.ofEpochMilli(epochMilli); - Date actual = this.converter.convert(instant, Date.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + Date actual = converter.convert(instant, Date.class); assertThat(actual.getTime()).isEqualTo(epochMilli); } @@ -1268,7 +1310,8 @@ void testInstantToDate(long epochMilli, ZoneId zoneId, LocalDateTime expected) void testInstantToSqlDate(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Instant instant = Instant.ofEpochMilli(epochMilli); - java.sql.Date actual = this.converter.convert(instant, java.sql.Date.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + java.sql.Date actual = converter.convert(instant, java.sql.Date.class); assertThat(actual.getTime()).isEqualTo(epochMilli); } @@ -1277,7 +1320,8 @@ void testInstantToSqlDate(long epochMilli, ZoneId zoneId, LocalDateTime expected void testInstantToCalendar(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Instant instant = Instant.ofEpochMilli(epochMilli); - Calendar actual = this.converter.convert(instant, Calendar.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + Calendar actual = converter.convert(instant, Calendar.class); assertThat(actual.getTime().getTime()).isEqualTo(epochMilli); assertThat(actual.getTimeZone()).isEqualTo(TimeZone.getTimeZone(zoneId)); } @@ -1287,7 +1331,8 @@ void testInstantToCalendar(long epochMilli, ZoneId zoneId, LocalDateTime expecte void testInstantToBigInteger(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Instant instant = Instant.ofEpochMilli(epochMilli); - BigInteger actual = this.converter.convert(instant, BigInteger.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + BigInteger actual = converter.convert(instant, BigInteger.class); assertThat(actual.longValue()).isEqualTo(epochMilli); } @@ -1296,7 +1341,8 @@ void testInstantToBigInteger(long epochMilli, ZoneId zoneId, LocalDateTime expec void testInstantToBigDecimal(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Instant instant = Instant.ofEpochMilli(epochMilli); - BigDecimal actual = this.converter.convert(instant, BigDecimal.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + BigDecimal actual = converter.convert(instant, BigDecimal.class); assertThat(actual.longValue()).isEqualTo(epochMilli); } @@ -1305,7 +1351,8 @@ void testInstantToBigDecimal(long epochMilli, ZoneId zoneId, LocalDateTime expec void testInstantToLocalDate(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Instant instant = Instant.ofEpochMilli(epochMilli); - LocalDate actual = this.converter.convert(instant, LocalDate.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDate actual = converter.convert(instant, LocalDate.class); assertThat(actual).isEqualTo(expected.toLocalDate()); } @@ -1314,18 +1361,18 @@ void testInstantToLocalDate(long epochMilli, ZoneId zoneId, LocalDateTime expect void testInstantToLocalTime(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Instant instant = Instant.ofEpochMilli(epochMilli); - LocalTime actual = this.converter.convert(instant, LocalTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalTime actual = converter.convert(instant, LocalTime.class); assertThat(actual).isEqualTo(expected.toLocalTime()); } - - - + @ParameterizedTest @MethodSource("epochMillis_withLocalDateTimeInformation") void testTimestampToLocalDateTime(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Timestamp date = new Timestamp(epochMilli); - LocalDateTime localDateTime = this.converter.convert(date, LocalDateTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDateTime localDateTime = converter.convert(date, LocalDateTime.class); assertThat(localDateTime).isEqualTo(expected); } @@ -1355,7 +1402,8 @@ void testCalendarToDouble(long epochMilli, ZoneId zoneId, LocalDate expected) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(epochMilli); - double d = this.converter.convert(calendar, double.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + double d = converter.convert(calendar, double.class); assertThat(d).isEqualTo((double)epochMilli); } @@ -1365,7 +1413,8 @@ void testCalendarToLocalDate(long epochMilli, ZoneId zoneId, LocalDate expected) Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(zoneId)); calendar.setTimeInMillis(epochMilli); - LocalDate localDate = this.converter.convert(calendar, LocalDate.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDate localDate = converter.convert(calendar, LocalDate.class); assertThat(localDate).isEqualTo(expected); } @@ -1375,7 +1424,8 @@ void testCalendarToLocalTime(long epochMilli, ZoneId zoneId, LocalDateTime expec Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(zoneId)); calendar.setTimeInMillis(epochMilli); - LocalTime actual = this.converter.convert(calendar, LocalTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalTime actual = converter.convert(calendar, LocalTime.class); assertThat(actual).isEqualTo(expected.toLocalTime()); } @@ -1385,7 +1435,8 @@ void testCalendarToZonedDateTime(long epochMilli, ZoneId zoneId, LocalDateTime e Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(zoneId)); calendar.setTimeInMillis(epochMilli); - ZonedDateTime actual = this.converter.convert(calendar, ZonedDateTime.class, createCustomZones(IGNORED)); + Converter converter = new Converter(createCustomZones(IGNORED)); + ZonedDateTime actual = converter.convert(calendar, ZonedDateTime.class); assertThat(actual.toLocalDateTime()).isEqualTo(expected); } @@ -1395,7 +1446,8 @@ void testCalendarToInstant(long epochMilli, ZoneId zoneId, LocalDateTime expecte Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(zoneId)); calendar.setTimeInMillis(epochMilli); - Instant actual = this.converter.convert(calendar, Instant.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + Instant actual = converter.convert(calendar, Instant.class); assertThat(actual.toEpochMilli()).isEqualTo(epochMilli); } @@ -1406,7 +1458,8 @@ void testCalendarToBigDecimal(long epochMilli, ZoneId zoneId, LocalDateTime expe Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(zoneId)); calendar.setTimeInMillis(epochMilli); - BigDecimal actual = this.converter.convert(calendar, BigDecimal.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + BigDecimal actual = converter.convert(calendar, BigDecimal.class); assertThat(actual.longValue()).isEqualTo(epochMilli); } @@ -1417,7 +1470,8 @@ void testCalendarToBigInteger(long epochMilli, ZoneId zoneId, LocalDateTime expe Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(zoneId)); calendar.setTimeInMillis(epochMilli); - BigInteger actual = this.converter.convert(calendar, BigInteger.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + BigInteger actual = converter.convert(calendar, BigInteger.class); assertThat(actual.longValue()).isEqualTo(epochMilli); } @@ -1426,7 +1480,8 @@ void testCalendarToBigInteger(long epochMilli, ZoneId zoneId, LocalDateTime expe void testDateToLocalTime(long epochMilli, ZoneId zoneId, LocalDateTime expected) { Date date = new Date(epochMilli); - LocalTime actual = this.converter.convert(date, LocalTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalTime actual = converter.convert(date, LocalTime.class); assertThat(actual).isEqualTo(expected.toLocalTime()); } @@ -1436,7 +1491,8 @@ void testCalendarToLocalDate_whenCalendarTimeZoneMatches(long epochMilli, ZoneId Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(zoneId)); calendar.setTimeInMillis(epochMilli); - LocalDate localDate = this.converter.convert(calendar, LocalDate.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDate localDate = converter.convert(calendar, LocalDate.class); assertThat(localDate).isEqualTo(expected); } @@ -1445,7 +1501,8 @@ void testCalendarToLocalDate_whenCalendarTimeZoneDoesNotMatchTarget_convertsTime Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(NEW_YORK)); calendar.setTimeInMillis(1687622249729L); - LocalDate localDate = this.converter.convert(calendar, LocalDate.class, createCustomZones(IGNORED)); + Converter converter = new Converter(createCustomZones(IGNORED)); + LocalDate localDate = converter.convert(calendar, LocalDate.class); assertThat(localDate) .hasYear(2023) @@ -1469,7 +1526,8 @@ void testCalendar_testRoundTripWithLocalDate() { assertThat(calendar.getTimeInMillis()).isEqualTo(1687622249729L); // Convert calendar calendar to TOKYO LocalDateTime - LocalDateTime localDateTime = this.converter.convert(calendar, LocalDateTime.class, createCustomZones(IGNORED)); + Converter converter = new Converter(createCustomZones(IGNORED)); + LocalDateTime localDateTime = converter.convert(calendar, LocalDateTime.class); assertThat(localDateTime) .hasYear(2023) @@ -1482,7 +1540,8 @@ void testCalendar_testRoundTripWithLocalDate() { // Convert Tokyo local date time to CHICAGO Calendar // We don't know the source ZoneId we are trying to convert. - Calendar actual = this.converter.convert(localDateTime, Calendar.class, createCustomZones(CHICAGO)); + converter = new Converter(createCustomZones(CHICAGO)); + Calendar actual = converter.convert(localDateTime, Calendar.class); assertThat(actual.get(Calendar.MONTH)).isEqualTo(5); assertThat(actual.get(Calendar.DAY_OF_MONTH)).isEqualTo(24); @@ -1498,7 +1557,8 @@ void toLong_fromLocalDate() { LocalDate localDate = LocalDate.now(); ConverterOptions options = chicagoZone(); - Long converted = this.converter.convert(localDate, Long.class, options); + Converter converter = new Converter(options); + Long converted = converter.convert(localDate, Long.class); assertThat(converted).isEqualTo(localDate.atStartOfDay(options.getZoneId()).toInstant().toEpochMilli()); } @@ -1506,7 +1566,8 @@ void toLong_fromLocalDate() @MethodSource("epochMillis_withLocalDateInformation") void testLongToLocalDate(long epochMilli, ZoneId zoneId, LocalDate expected) { - LocalDate localDate = this.converter.convert(epochMilli, LocalDate.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDate localDate = converter.convert(epochMilli, LocalDate.class); assertThat(localDate).isEqualTo(expected); } @@ -1515,7 +1576,8 @@ void testLongToLocalDate(long epochMilli, ZoneId zoneId, LocalDate expected) @MethodSource("epochMillis_withLocalDateInformation") void testZonedDateTimeToLocalDate(long epochMilli, ZoneId zoneId, LocalDate expected) { - LocalDate localDate = this.converter.convert(epochMilli, LocalDate.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDate localDate = converter.convert(epochMilli, LocalDate.class); assertThat(localDate).isEqualTo(expected); } @@ -1526,7 +1588,8 @@ void testZonedDateTimeToLocalDate(long epochMilli, ZoneId zoneId, LocalDate expe void testInstantToLocalDate(long epochMilli, ZoneId zoneId, LocalDate expected) { Instant instant = Instant.ofEpochMilli(epochMilli); - LocalDate localDate = this.converter.convert(instant, LocalDate.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDate localDate = converter.convert(instant, LocalDate.class); assertThat(localDate).isEqualTo(expected); } @@ -1536,7 +1599,8 @@ void testInstantToLocalDate(long epochMilli, ZoneId zoneId, LocalDate expected) void testDateToLocalDate(long epochMilli, ZoneId zoneId, LocalDate expected) { Date date = new Date(epochMilli); - LocalDate localDate = this.converter.convert(date, LocalDate.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDate localDate = converter.convert(date, LocalDate.class); assertThat(localDate).isEqualTo(expected); } @@ -1546,7 +1610,8 @@ void testDateToLocalDate(long epochMilli, ZoneId zoneId, LocalDate expected) void testSqlDateToLocalDate(long epochMilli, ZoneId zoneId, LocalDate expected) { java.sql.Date date = new java.sql.Date(epochMilli); - LocalDate localDate = this.converter.convert(date, LocalDate.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDate localDate = converter.convert(date, LocalDate.class); assertThat(localDate).isEqualTo(expected); } @@ -1556,7 +1621,8 @@ void testSqlDateToLocalDate(long epochMilli, ZoneId zoneId, LocalDate expected) void testTimestampToLocalDate(long epochMilli, ZoneId zoneId, LocalDate expected) { Timestamp date = new Timestamp(epochMilli); - LocalDate localDate = this.converter.convert(date, LocalDate.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalDate localDate = converter.convert(date, LocalDate.class); assertThat(localDate).isEqualTo(expected); } @@ -1566,7 +1632,8 @@ void testTimestampToLocalDate(long epochMilli, ZoneId zoneId, LocalDate expected void testLongToBigInteger(Object source, Number number) { long expected = number.longValue(); - BigInteger actual = this.converter.convert(source, BigInteger.class, createCustomZones(null)); + Converter converter = new Converter(createCustomZones(null)); + BigInteger actual = converter.convert(source, BigInteger.class); assertThat(actual).isEqualTo(BigInteger.valueOf(expected)); } @@ -1575,7 +1642,8 @@ void testLongToBigInteger(Object source, Number number) @MethodSource("epochMillis_withLocalDateInformation") void testLongToLocalTime(long epochMilli, ZoneId zoneId, LocalDate expected) { - LocalTime actual = this.converter.convert(epochMilli, LocalTime.class, createCustomZones(zoneId)); + Converter converter = new Converter(createCustomZones(zoneId)); + LocalTime actual = converter.convert(epochMilli, LocalTime.class); assertThat(actual).isEqualTo(Instant.ofEpochMilli(epochMilli).atZone(zoneId).toLocalTime()); } @@ -1584,7 +1652,8 @@ void testLongToLocalTime(long epochMilli, ZoneId zoneId, LocalDate expected) @MethodSource("localDateTimeConversion_params") void testLocalDateToLong(long epochMilli, ZoneId sourceZoneId, LocalDateTime initial, ZoneId targetZoneId, LocalDateTime expected) { - long milli = this.converter.convert(initial, long.class, createCustomZones(sourceZoneId)); + Converter converter = new Converter(createCustomZones(sourceZoneId)); + long milli = converter.convert(initial, long.class); assertThat(milli).isEqualTo(epochMilli); } @@ -1601,10 +1670,12 @@ private static Stream localDateTimeConversion_params() { @MethodSource("localDateTimeConversion_params") void testLocalDateTimeToLong(long epochMilli, ZoneId sourceZoneId, LocalDateTime initial, ZoneId targetZoneId, LocalDateTime expected) { - long milli = this.converter.convert(initial, long.class, createCustomZones(sourceZoneId)); + Converter converter = new Converter(createCustomZones(sourceZoneId)); + long milli = converter.convert(initial, long.class); assertThat(milli).isEqualTo(epochMilli); - LocalDateTime actual = this.converter.convert(milli, LocalDateTime.class, createCustomZones(targetZoneId)); + converter = new Converter(createCustomZones(targetZoneId)); + LocalDateTime actual = converter.convert(milli, LocalDateTime.class); assertThat(actual).isEqualTo(expected); } @@ -1612,10 +1683,12 @@ void testLocalDateTimeToLong(long epochMilli, ZoneId sourceZoneId, LocalDateTime @MethodSource("localDateTimeConversion_params") void testLocalDateTimeToInstant(long epochMilli, ZoneId sourceZoneId, LocalDateTime initial, ZoneId targetZoneId, LocalDateTime expected) { - Instant intermediate = this.converter.convert(initial, Instant.class, createCustomZones(sourceZoneId)); + Converter converter = new Converter(createCustomZones(sourceZoneId)); + Instant intermediate = converter.convert(initial, Instant.class); assertThat(intermediate.toEpochMilli()).isEqualTo(epochMilli); - LocalDateTime actual = this.converter.convert(intermediate, LocalDateTime.class, createCustomZones(targetZoneId)); + converter = new Converter(createCustomZones(targetZoneId)); + LocalDateTime actual = converter.convert(intermediate, LocalDateTime.class); assertThat(actual).isEqualTo(expected); } @@ -1623,10 +1696,12 @@ void testLocalDateTimeToInstant(long epochMilli, ZoneId sourceZoneId, LocalDateT @MethodSource("localDateTimeConversion_params") void testLocalDateTimeToAtomicLong(long epochMilli, ZoneId sourceZoneId, LocalDateTime initial, ZoneId targetZoneId, LocalDateTime expected) { - AtomicLong milli = this.converter.convert(initial, AtomicLong.class, createCustomZones(sourceZoneId)); + Converter converter = new Converter(createCustomZones(sourceZoneId)); + AtomicLong milli = converter.convert(initial, AtomicLong.class); assertThat(milli.longValue()).isEqualTo(epochMilli); - LocalDateTime actual = this.converter.convert(milli, LocalDateTime.class, createCustomZones(targetZoneId)); + converter = new Converter(createCustomZones(targetZoneId)); + LocalDateTime actual = converter.convert(milli, LocalDateTime.class); assertThat(actual).isEqualTo(expected); } @@ -1634,10 +1709,12 @@ void testLocalDateTimeToAtomicLong(long epochMilli, ZoneId sourceZoneId, LocalDa @MethodSource("localDateTimeConversion_params") void testLocalDateTimeToZonedDateTime(long epochMilli, ZoneId sourceZoneId, LocalDateTime initial, ZoneId targetZoneId, LocalDateTime expected) { - ZonedDateTime intermediate = this.converter.convert(initial, ZonedDateTime.class, createCustomZones(sourceZoneId)); + Converter converter = new Converter(createCustomZones(sourceZoneId)); + ZonedDateTime intermediate = converter.convert(initial, ZonedDateTime.class); assertThat(intermediate.toInstant().toEpochMilli()).isEqualTo(epochMilli); - LocalDateTime actual = this.converter.convert(intermediate, LocalDateTime.class, createCustomZones(targetZoneId)); + converter = new Converter(createCustomZones(targetZoneId)); + LocalDateTime actual = converter.convert(intermediate, LocalDateTime.class); assertThat(actual).isEqualTo(expected); } @@ -1645,10 +1722,12 @@ void testLocalDateTimeToZonedDateTime(long epochMilli, ZoneId sourceZoneId, Loca @MethodSource("localDateTimeConversion_params") void testLocalDateTimeToBigInteger(long epochMilli, ZoneId sourceZoneId, LocalDateTime initial, ZoneId targetZoneId, LocalDateTime expected) { - BigInteger milli = this.converter.convert(initial, BigInteger.class, createCustomZones(sourceZoneId)); + Converter converter = new Converter(createCustomZones(sourceZoneId)); + BigInteger milli = converter.convert(initial, BigInteger.class); assertThat(milli.longValue()).isEqualTo(epochMilli); - LocalDateTime actual = this.converter.convert(milli, LocalDateTime.class, createCustomZones(targetZoneId)); + converter = new Converter(createCustomZones(targetZoneId)); + LocalDateTime actual = converter.convert(milli, LocalDateTime.class); assertThat(actual).isEqualTo(expected); } @@ -1657,10 +1736,12 @@ void testLocalDateTimeToBigInteger(long epochMilli, ZoneId sourceZoneId, LocalDa @MethodSource("localDateTimeConversion_params") void testLocalDateTimeToBigDecimal(long epochMilli, ZoneId sourceZoneId, LocalDateTime initial, ZoneId targetZoneId, LocalDateTime expected) { - BigDecimal milli = this.converter.convert(initial, BigDecimal.class, createCustomZones(sourceZoneId)); + Converter converter = new Converter(createCustomZones(sourceZoneId)); + BigDecimal milli = converter.convert(initial, BigDecimal.class); assertThat(milli.longValue()).isEqualTo(epochMilli); - LocalDateTime actual = this.converter.convert(milli, LocalDateTime.class, createCustomZones(targetZoneId)); + converter = new Converter(createCustomZones(targetZoneId)); + LocalDateTime actual = converter.convert(milli, LocalDateTime.class); assertThat(actual).isEqualTo(expected); } @@ -3208,8 +3289,11 @@ void toCharacter_whenTrue_withDefaultOptions_andObjectType_returnsCommonValue(Ob @MethodSource("trueValues") void toCharacter_whenTrue_withCustomOptions_returnsTrueCharacter(Object source) { - assertThat(this.converter.convert(source, Character.class, TF_OPTIONS)).isEqualTo('T'); - assertThat(this.converter.convert(source, Character.class, YN_OPTIONS)).isEqualTo('Y'); + Converter converter = new Converter(TF_OPTIONS); + assertThat(converter.convert(source, Character.class)).isEqualTo('T'); + + converter = new Converter(YN_OPTIONS); + assertThat(converter.convert(source, Character.class)).isEqualTo('Y'); } @@ -3242,8 +3326,11 @@ void toCharacter_whenFalse_withDefaultOptions_andObjectType_returnsCommonValue(O @MethodSource("falseValues") void toCharacter_whenFalse_withCustomOptions_returnsTrueCharacter(Object source) { - assertThat(this.converter.convert(source, Character.class, TF_OPTIONS)).isEqualTo('F'); - assertThat(this.converter.convert(source, Character.class, YN_OPTIONS)).isEqualTo('N'); + Converter converter = new Converter(TF_OPTIONS); + assertThat(converter.convert(source, Character.class)).isEqualTo('F'); + + converter = new Converter(YN_OPTIONS); + assertThat(converter.convert(source, Character.class)).isEqualTo('N'); } @@ -3929,7 +4016,7 @@ void testDumbNumberToUUIDProvesInheritance() assert uuid.toString().equals("00000000-0000-0000-0000-0000000003e8"); // Add in conversion - this.converter.addConversion(DumbNumber.class, UUID.class, (fromInstance, converter, options) -> { + this.converter.addConversion(DumbNumber.class, UUID.class, (fromInstance, converter) -> { DumbNumber bigDummy = (DumbNumber) fromInstance; BigInteger mask = BigInteger.valueOf(Long.MAX_VALUE); long mostSignificantBits = bigDummy.shiftRight(64).and(mask).longValue(); @@ -3955,7 +4042,7 @@ void testUUIDtoDumbNumber() assert 1000L == ((Number) o).longValue(); // Add in conversion - this.converter.addConversion(UUID.class, DumbNumber.class, (fromInstance, converter, options) -> { + this.converter.addConversion(UUID.class, DumbNumber.class, (fromInstance, converter) -> { UUID uuid1 = (UUID) fromInstance; BigInteger mostSignificant = BigInteger.valueOf(uuid1.getMostSignificantBits()); BigInteger leastSignificant = BigInteger.valueOf(uuid1.getLeastSignificantBits()); @@ -3986,13 +4073,13 @@ void testUUIDtoBoolean() .hasMessageContaining("Unsupported conversion, source type [UUID (00000000-0000-0000-0000-000000000000)] target type 'Boolean'"); // Add in conversions - this.converter.addConversion(UUID.class, boolean.class, (fromInstance, converter, options) -> { + this.converter.addConversion(UUID.class, boolean.class, (fromInstance, converter) -> { UUID uuid1 = (UUID) fromInstance; return !"00000000-0000-0000-0000-000000000000".equals(uuid1.toString()); }); // Add in conversions - this.converter.addConversion(boolean.class, UUID.class, (fromInstance, converter, options) -> { + this.converter.addConversion(boolean.class, UUID.class, (fromInstance, converter) -> { boolean state = (Boolean)fromInstance; if (state) { return "00000000-0000-0000-0000-000000000001"; @@ -4060,13 +4147,13 @@ static String reverseString(String in) @Test void testNormieToWeirdoAndBack() { - this.converter.addConversion(Normie.class, Weirdo.class, (fromInstance, converter, options) -> { + this.converter.addConversion(Normie.class, Weirdo.class, (fromInstance, converter) -> { Normie normie = (Normie) fromInstance; Weirdo weirdo = new Weirdo(normie.name); return weirdo; }); - this.converter.addConversion(Weirdo.class, Normie.class, (fromInstance, converter, options) -> { + this.converter.addConversion(Weirdo.class, Normie.class, (fromInstance, converter) -> { Weirdo weirdo = (Weirdo) fromInstance; Normie normie = new Normie(reverseString(weirdo.name)); return normie; @@ -4182,41 +4269,45 @@ private static Stream stringToCharArrayParams() { @ParameterizedTest @MethodSource("stringToByteArrayParams") void testStringToByteArray(String source, Charset charSet, byte[] expected) { - byte[] actual = this.converter.convert(source, byte[].class, createCharsetOptions(charSet)); + Converter converter = new Converter(createCharsetOptions(charSet)); + byte[] actual = converter.convert(source, byte[].class); assertThat(actual).isEqualTo(expected); } @ParameterizedTest @MethodSource("stringToByteArrayParams") void testStringToByteBuffer(String source, Charset charSet, byte[] expected) { - ByteBuffer actual = this.converter.convert(source, ByteBuffer.class, createCharsetOptions(charSet)); + Converter converter = new Converter(createCharsetOptions(charSet)); + ByteBuffer actual = converter.convert(source, ByteBuffer.class); assertThat(actual).isEqualTo(ByteBuffer.wrap(expected)); } @ParameterizedTest @MethodSource("stringToByteArrayParams") void testByteArrayToString(String expected, Charset charSet, byte[] source) { - String actual = this.converter.convert(source, String.class, createCharsetOptions(charSet)); + Converter converter = new Converter(createCharsetOptions(charSet)); + String actual = converter.convert(source, String.class); assertThat(actual).isEqualTo(expected); } @ParameterizedTest @MethodSource("stringToCharArrayParams") void testCharArrayToString(String expected, Charset charSet, char[] source) { - String actual = this.converter.convert(source, String.class, createCharsetOptions(charSet)); + Converter converter = new Converter(createCharsetOptions(charSet)); + String actual = converter.convert(source, String.class); assertThat(actual).isEqualTo(expected); } @ParameterizedTest @MethodSource("stringToCharArrayParams") void testStringToCharArray(String source, Charset charSet, char[] expected) { - char[] actual = this.converter.convert(source, char[].class, createCharsetOptions(charSet)); + Converter converter = new Converter(createCharsetOptions(charSet)); + char[] actual = converter.convert(source, char[].class); assertThat(actual).isEqualTo(expected); } @Test - void testKnownUnsupportedConversions() - { + void testKnownUnsupportedConversions() { assertThatThrownBy(() -> converter.convert((byte)50, Date.class)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Unsupported conversion"); @@ -4230,8 +4321,7 @@ void testKnownUnsupportedConversions() .hasMessageContaining("Unsupported conversion"); } - private ConverterOptions createCharsetOptions(final Charset charset) - { + private ConverterOptions createCharsetOptions(final Charset charset) { return new ConverterOptions() { @Override public T getCustomOption(String name) { @@ -4245,8 +4335,7 @@ public Charset getCharset () { }; } - private ConverterOptions createCustomZones(final ZoneId targetZoneId) - { + private ConverterOptions createCustomZones(final ZoneId targetZoneId) { return new ConverterOptions() { @Override public T getCustomOption(String name) { @@ -4260,8 +4349,7 @@ public ZoneId getZoneId() { }; } - private static ConverterOptions createCustomBooleanCharacter(final Character trueChar, final Character falseChar) - { + private static ConverterOptions createCustomBooleanCharacter(final Character trueChar, final Character falseChar) { return new ConverterOptions() { @Override public T getCustomOption(String name) { diff --git a/src/test/java/com/cedarsoftware/util/convert/StringConversionsTests.java b/src/test/java/com/cedarsoftware/util/convert/StringConversionsTests.java index 5144f5c9..7ecf93b6 100644 --- a/src/test/java/com/cedarsoftware/util/convert/StringConversionsTests.java +++ b/src/test/java/com/cedarsoftware/util/convert/StringConversionsTests.java @@ -1,12 +1,5 @@ package com.cedarsoftware.util.convert; -import com.cedarsoftware.util.ClassUtilities; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - import java.sql.Timestamp; import java.time.Instant; import java.time.LocalDate; @@ -21,6 +14,13 @@ import java.util.Date; import java.util.stream.Stream; +import com.cedarsoftware.util.ClassUtilities; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + import static org.assertj.core.api.Assertions.assertThat; class StringConversionsTests { @@ -210,7 +210,8 @@ void toOffsetDateTime_dateUtilitiesParseFallback(String input, long epochMilli) // ZoneId options not used since all string format has zone in it somewhere. // This is how json-io would use the convert. ConverterOptions options = createCustomZones(SOUTH_POLE); - OffsetDateTime actual = converter.convert(input, OffsetDateTime.class, options); + Converter converter = new Converter(options); + OffsetDateTime actual = converter.convert(input, OffsetDateTime.class); assertThat(actual.toInstant().toEpochMilli()).isEqualTo(epochMilli); assertThat(actual.getOffset()).isNotEqualTo(ZoneOffset.of("+13:00"));