Class NumericalHelper


  • public final class NumericalHelper
    extends java.lang.Object
    Author:
    Eugen Neufeld
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Number getDefaultValue​(java.lang.Class<?> instanceClass)
      Returns the default value for a given number instance class.
      static boolean isDouble​(java.lang.Class<?> instanceClass)
      Whether the given class is a double.
      static boolean isInteger​(java.lang.Class<?> instanceClass)
      Whether the given class is an integer.
      static java.lang.Object numberToInstanceClass​(java.lang.Number number, java.lang.Class<?> instanceClass)
      Converts the given number to an value of the instance class type.
      static java.text.DecimalFormat setupFormat​(java.util.Locale locale, java.lang.Class<?> instanceClass)
      Sets up a DecimalFormat based on the given locale on instance class.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setupFormat

        public static java.text.DecimalFormat setupFormat​(java.util.Locale locale,
                                                          java.lang.Class<?> instanceClass)
        Sets up a DecimalFormat based on the given locale on instance class.
        Parameters:
        locale - the locale of the current application
        instanceClass - the instance class of the number
        Returns:
        the format
      • getDefaultValue

        public static java.lang.Number getDefaultValue​(java.lang.Class<?> instanceClass)
        Returns the default value for a given number instance class.
        Parameters:
        instanceClass - the class
        Returns:
        the default value
      • isDouble

        public static boolean isDouble​(java.lang.Class<?> instanceClass)
        Whether the given class is a double.
        Parameters:
        instanceClass - the class to check
        Returns:
        true if double, false otherwise
      • isInteger

        public static boolean isInteger​(java.lang.Class<?> instanceClass)
        Whether the given class is an integer.
        Parameters:
        instanceClass - the class to check
        Returns:
        true if integer, false otherwise
      • numberToInstanceClass

        public static java.lang.Object numberToInstanceClass​(java.lang.Number number,
                                                             java.lang.Class<?> instanceClass)
        Converts the given number to an value of the instance class type.
        Parameters:
        number - the number to convert
        instanceClass - the instance which the result must conform to
        Returns:
        the converted value