Class ConversionUtil

java.lang.Object
org.bhn.promotion.core.utils.ConversionUtil

public class ConversionUtil extends Object
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 Details

    • convertObjectToInteger

      public static Integer convertObjectToInteger(Object object)
      Converts a given Object to a Integer.

      Supports conversion from Number subclasses (e.g., Integer, Long, Float) and String.

      Parameters:
      object - the object to convert
      Returns:
      the converted Integer value, or null if the input is null
      Throws:
      IllegalArgumentException - if the input cannot be converted to a Integer
    • convertObjectToBigDecimal

      public static BigDecimal convertObjectToBigDecimal(Object object)
      Converts a given Object to a BigDecimal.

      Supports conversion from Number subclasses and String representations of decimal numbers.

      Parameters:
      object - the object to convert
      Returns:
      the converted BigDecimal value, or null if the input is null
      Throws:
      IllegalArgumentException - if the input cannot be converted to a BigDecimal
    • sanitizeAndWrapInHtml

      public static String sanitizeAndWrapInHtml(String rawContent)
      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