Class TypeCasting
java.lang.Object
com.flagsmith.flagengine.utils.types.TypeCasting
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 BooleanIs the object of type Boolean?.static BooleanIs the object of type Double?.static BooleanIs the object of type Float?.static BooleanIs the object of type Integer?.static BooleanIs the object of type Semver?.static BooleanConvert the object to Boolean.static DoubleConvert the object to Double.static FloatConvert the object to float.static IntegerConvert to object to Integer.static org.apache.maven.artifact.versioning.ComparableVersionConvert 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
-