From abe77782ef0f3ad9c1ae97290538436e469c9528 Mon Sep 17 00:00:00 2001 From: John DeRegnaucourt Date: Wed, 10 Jan 2024 01:25:53 -0500 Subject: [PATCH] Updated method name to ensure it was not misleading --- .../com/cedarsoftware/util/convert/Converter.java | 12 ++++++------ .../cedarsoftware/util/convert/NumberConversion.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/cedarsoftware/util/convert/Converter.java b/src/main/java/com/cedarsoftware/util/convert/Converter.java index 004d5a82..0ddbeef9 100644 --- a/src/main/java/com/cedarsoftware/util/convert/Converter.java +++ b/src/main/java/com/cedarsoftware/util/convert/Converter.java @@ -410,10 +410,10 @@ private static void buildFactoryConversions() { // BigDecimal conversions supported DEFAULT_FACTORY.put(pair(Void.class, BigDecimal.class), VoidConversion::toNull); - DEFAULT_FACTORY.put(pair(Byte.class, BigDecimal.class), NumberConversion::numberToBigDecimal); - DEFAULT_FACTORY.put(pair(Short.class, BigDecimal.class), NumberConversion::numberToBigDecimal); - DEFAULT_FACTORY.put(pair(Integer.class, BigDecimal.class), NumberConversion::numberToBigDecimal); - DEFAULT_FACTORY.put(pair(Long.class, BigDecimal.class), NumberConversion::numberToBigDecimal); + DEFAULT_FACTORY.put(pair(Byte.class, BigDecimal.class), NumberConversion::longToBigDecimal); + DEFAULT_FACTORY.put(pair(Short.class, BigDecimal.class), NumberConversion::longToBigDecimal); + DEFAULT_FACTORY.put(pair(Integer.class, BigDecimal.class), NumberConversion::longToBigDecimal); + DEFAULT_FACTORY.put(pair(Long.class, BigDecimal.class), NumberConversion::longToBigDecimal); DEFAULT_FACTORY.put(pair(Float.class, BigDecimal.class), (fromInstance, converter, options) -> BigDecimal.valueOf((Float) fromInstance)); DEFAULT_FACTORY.put(pair(Double.class, BigDecimal.class), (fromInstance, converter, options) -> BigDecimal.valueOf((Double) fromInstance)); DEFAULT_FACTORY.put(pair(Boolean.class, BigDecimal.class), (fromInstance, converter, options) -> (Boolean) fromInstance ? BigDecimal.ONE : BigDecimal.ZERO); @@ -421,8 +421,8 @@ private static void buildFactoryConversions() { DEFAULT_FACTORY.put(pair(BigDecimal.class, BigDecimal.class), Converter::identity); DEFAULT_FACTORY.put(pair(BigInteger.class, BigDecimal.class), (fromInstance, converter, options) -> new BigDecimal((BigInteger) fromInstance)); DEFAULT_FACTORY.put(pair(AtomicBoolean.class, BigDecimal.class), (fromInstance, converter, options) -> ((AtomicBoolean) fromInstance).get() ? BigDecimal.ONE : BigDecimal.ZERO); - DEFAULT_FACTORY.put(pair(AtomicInteger.class, BigDecimal.class), NumberConversion::numberToBigDecimal); - DEFAULT_FACTORY.put(pair(AtomicLong.class, BigDecimal.class), NumberConversion::numberToBigDecimal); + DEFAULT_FACTORY.put(pair(AtomicInteger.class, BigDecimal.class), NumberConversion::longToBigDecimal); + DEFAULT_FACTORY.put(pair(AtomicLong.class, BigDecimal.class), NumberConversion::longToBigDecimal); DEFAULT_FACTORY.put(pair(Date.class, BigDecimal.class), (fromInstance, converter, options) -> BigDecimal.valueOf(((Date) fromInstance).getTime())); DEFAULT_FACTORY.put(pair(java.sql.Date.class, BigDecimal.class), (fromInstance, converter, options) -> BigDecimal.valueOf(((Date) fromInstance).getTime())); DEFAULT_FACTORY.put(pair(Timestamp.class, BigDecimal.class), (fromInstance, converter, options) -> BigDecimal.valueOf(((Date) fromInstance).getTime())); diff --git a/src/main/java/com/cedarsoftware/util/convert/NumberConversion.java b/src/main/java/com/cedarsoftware/util/convert/NumberConversion.java index fdd6d12c..e6c859a9 100644 --- a/src/main/java/com/cedarsoftware/util/convert/NumberConversion.java +++ b/src/main/java/com/cedarsoftware/util/convert/NumberConversion.java @@ -32,7 +32,7 @@ public static double toDoubleZero(Object from, Converter converter, ConverterOpt return 0.0d; } - public static BigDecimal numberToBigDecimal(Object from, Converter converter, ConverterOptions options) { + public static BigDecimal longToBigDecimal(Object from, Converter converter, ConverterOptions options) { return BigDecimal.valueOf(((Number) from).longValue()); }