Package org.bhn.promotion.core.utils
Class ConversionUtil
java.lang.Object
org.bhn.promotion.core.utils.ConversionUtil
Utility class for safely converting generic
Object instances into common numeric types
such as Double and BigDecimal.
Supports conversion from various Number types and String representations of
numbers. Throws IllegalArgumentException if the input cannot be parsed into the expected
numeric type.
-
Method Summary
Modifier and TypeMethodDescriptionstatic BigDecimalconvertObjectToBigDecimal(Object object) Converts a givenObjectto aBigDecimal.static IntegerconvertObjectToInteger(Object object) static StringsanitizeAndWrapInHtml(String rawContent) Escapes HTML characters in the input text and wraps it inside a styled HTML <div> and <p> tag block.
-
Method Details
-
convertObjectToInteger
Converts a givenObjectto aInteger.Supports conversion from
Numbersubclasses (e.g., Integer, Long, Float) andString.- Parameters:
object- the object to convert- Returns:
- the converted
Integervalue, ornullif the input isnull - Throws:
IllegalArgumentException- if the input cannot be converted to aInteger
-
convertObjectToBigDecimal
Converts a givenObjectto aBigDecimal.Supports conversion from
Numbersubclasses andStringrepresentations of decimal numbers.- Parameters:
object- the object to convert- Returns:
- the converted
BigDecimalvalue, ornullif the input isnull - Throws:
IllegalArgumentException- if the input cannot be converted to aBigDecimal
-
sanitizeAndWrapInHtml
Escapes HTML characters in the input text and wraps it inside a styled HTML <div> and <p> tag block.- Parameters:
rawContent- the raw input string (e.g., description or terms)- Returns:
- sanitized and formatted HTML string
-