Class CodeUtils
java.lang.Object
com.github.javaparser.generator.core.utils.CodeUtils
-
Method Summary
-
Method Details
-
castValue
Cast the value if the current type doesn't match the required type.
Given the following example:int withoutCast = 1; double withCast = (double) 1;
The variable withoutCast doesn't need to be casted, since we have int as required type and int as value type. While in the variable withCast we have double as required type and int as value type.- Parameters:
value
- The value to be returned.requiredType
- The expected type to be casted if needed.valueType
- The type of the value to be returned.- Returns:
- The value casted if needed.
-