Class TypeCasting

java.lang.Object
com.flagsmith.flagengine.utils.types.TypeCasting

public class TypeCasting
extends Object
  • Constructor Details

    • TypeCasting

      public TypeCasting()
  • Method Details

    • 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.
    • 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.
    • toDouble

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

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

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

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

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

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

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

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

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

      public static Boolean isSemver​(Object str)
      Is the object of type Semver?.
      Parameters:
      str - Object to type check.
    • 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