Class TypeCasting
java.lang.Object
com.flagsmith.flagengine.utils.types.TypeCasting
public class TypeCasting extends Object
-
Constructor Summary
Constructors Constructor Description TypeCasting() -
Method Summary
Modifier and Type Method Description static Booleancompare(SegmentConditions condition, Comparable value1, Comparable value2)Run comparison with condition of primitive type.static Booleancompare(SegmentConditions condition, Object value1, Object value2)Compare the values value1 and value2 with the provided condition.static BooleancompareModulo(String conditionValue, Object traitValue)Modulo is a special case as the condition value holds both the divisor and remainder.static BooleanisBoolean(Object str)Is the object of type Boolean?.static BooleanisDouble(Object number)Is the object of type Double?.static BooleanisFloat(Object number)Is the object of type Float?.static BooleanisInteger(Object number)Is the object of type Integer?.static BooleanisSemver(Object str)Is the object of type Semver?.static BooleantoBoolean(Object str)Convert the object to Boolean.static DoubletoDouble(Object number)Convert the object to Double.static FloattoFloat(Object number)Convert the object to float.static IntegertoInteger(Object number)Convert to object to Integer.static org.apache.maven.artifact.versioning.ComparableVersiontoSemver(Object str)Convert the object to Semver.
-
Constructor Details
-
TypeCasting
public TypeCasting()
-
-
Method Details
-
compare
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
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
Convert the object to Double.- Parameters:
number- Object to convert to Double.
-
isDouble
Is the object of type Double?.- Parameters:
number- Object to type check.
-
toFloat
Convert the object to float.- Parameters:
number- Object to convert to Float.
-
isFloat
Is the object of type Float?.- Parameters:
number- Object to type check.
-
toInteger
Convert to object to Integer.- Parameters:
number- Object to convert to Integer.
-
isInteger
Is the object of type Integer?.- Parameters:
number- Object to type check.
-
toBoolean
Convert the object to Boolean.- Parameters:
str- Object to convert to Boolean.
-
isBoolean
Is the object of type Boolean?.- Parameters:
str- Object to type check.
-
toSemver
Convert the object to Semver.- Parameters:
str- Object to convert to Semver.
-
isSemver
Is the object of type Semver?.- Parameters:
str- Object to type check.
-
compareModulo
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
-