Class TypeCasting


  • public class TypeCasting
    extends Object
    • Constructor Detail

      • TypeCasting

        public TypeCasting()
    • Method Detail

      • compare

        public static Boolean compare​(SegmentConditions condition,
                                      Object value1,
                                      Object value2)
        Compare the values value1 and value2 with the provided condition.
        Parameters:
        condition - SegmentCondition criteria to compare values against.
        value1 - Value to compare.
        value2 - Value to compare against.
        Returns:
      • compare

        public static Boolean compare​(SegmentConditions condition,
                                      Comparable value1,
                                      Comparable value2)
        Run comparison with condition of primitive type.
        Parameters:
        condition - SegmentCondition criteria to compare values against.
        value1 - Value to compare.
        value2 - Value to compare against.
        Returns:
      • toDouble

        public static Double toDouble​(Object number)
        Convert the object to Double.
        Parameters:
        number - Object to convert to Double.
        Returns:
      • isDouble

        public static Boolean isDouble​(Object number)
        Is the object of type Double?.
        Parameters:
        number - Object to type check.
        Returns:
      • toFloat

        public static Float toFloat​(Object number)
        Convert the object to float.
        Parameters:
        number - Object to convert to Float.
        Returns:
      • isFloat

        public static Boolean isFloat​(Object number)
        Is the object of type Float?.
        Parameters:
        number - Object to type check.
        Returns:
      • toInteger

        public static Integer toInteger​(Object number)
        Convert to object to Integer.
        Parameters:
        number - Object to convert to Integer.
        Returns:
      • isInteger

        public static Boolean isInteger​(Object number)
        Is the object of type Integer?.
        Parameters:
        number - Object to type check.
        Returns:
      • toBoolean

        public static Boolean toBoolean​(Object str)
        Convert the object to Boolean.
        Parameters:
        str - Object to convert to Boolean.
        Returns:
      • isBoolean

        public static Boolean isBoolean​(Object str)
        Is the object of type Boolean?.
        Parameters:
        str - Object to type check.
        Returns:
      • toSemver

        public static org.apache.maven.artifact.versioning.ComparableVersion toSemver​(Object str)
        Convert the object to Semver.
        Parameters:
        str - Object to convert to Semver.
        Returns:
      • isSemver

        public static Boolean isSemver​(Object str)
        Is the object of type Semver?.
        Parameters:
        str - Object to type check.
        Returns:
      • compareModulo

        public static Boolean compareModulo​(String conditionValue,
                                            Object traitValue)
        Modulo is a special case as the condition value holds both the divisor and remainder. This method compares the conditionValue and the traitValue by dividing the traitValue by the divisor and verifying that it correctly equals the remainder.
        Parameters:
        conditionValue - conditionValue in the format 'divisor|remainder'
        traitValue - the value of the matched trait
        Returns:
        true if expression evaluates to true, false if unable to evaluate expression or it evaluates to false