Skip to content

Commit

Permalink
Updated method name to ensure it was not misleading
Browse files Browse the repository at this point in the history
  • Loading branch information
jdereg committed Jan 10, 2024
1 parent 1f75966 commit abe7778
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/main/java/com/cedarsoftware/util/convert/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,19 +410,19 @@ 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);
DEFAULT_FACTORY.put(pair(Character.class, BigDecimal.class), (fromInstance, converter, options) -> BigDecimal.valueOf(((char) fromInstance)));
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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down

0 comments on commit abe7778

Please sign in to comment.