public SoyExpression coerceToString ( ) { if ( soyRuntimeType . isKnownString ( ) && ! isBoxed ( ) ) { return this ; } if ( BytecodeUtils . isPrimitive ( resultType ( ) ) ) { if ( resultType ( ) . equals ( Type . BOOLEAN_TYPE ) ) { return forString ( MethodRef . BOOLEAN_TO_STRING . invoke ( delegate ) ) ; } else if ( resultType ( ) . equals ( Type . DOUBLE_TYPE ) ) { return forString ( MethodRef . DOUBLE_TO_STRING . invoke ( delegate ) ) ; } else if ( resultType ( ) . equals ( Type . LONG_TYPE ) ) { return forString ( MethodRef . LONG_TO_STRING . invoke ( delegate ) ) ; } else { throw new AssertionError ( "resultType(): " + resultType ( ) + " is not a valid type for a SoyExpression" ) ; } } if ( ! isBoxed ( ) ) { // this is for unboxed reference types (strings, lists, protos) String.valueOf handles null // implicitly return forString ( MethodRef . STRING_VALUE_OF . invoke ( delegate ) ) ; } return forString ( MethodRef . RUNTIME_COERCE_TO_STRING . invoke ( delegate ) ) ; }
Coerce this expression to a string value .