private void generateTemplateExpressionMethod ( ComponentExposedTypeGenerator exposedTypeGenerator , TemplateExpression expression , String templateName ) { MethodSpec . Builder templateExpressionMethodBuilder = MethodSpec . methodBuilder ( expression . getId ( ) ) . addModifiers ( Modifier . PUBLIC ) . addAnnotation ( JsMethod . class ) . addAnnotation ( getUnusableByJSAnnotation ( ) ) . returns ( expression . getType ( ) ) ; String expressionPosition = templateName ; if ( expression . getLineInHtml ( ) != null ) { expressionPosition += ", line " + expression . getLineInHtml ( ) ; } templateExpressionMethodBuilder . addComment ( expressionPosition ) ; expression . getParameters ( ) . forEach ( parameter -> templateExpressionMethodBuilder . addParameter ( parameter . getType ( ) , parameter . getName ( ) ) ) ; if ( expression . isReturnString ( ) ) { templateExpressionMethodBuilder . addStatement ( "return $T.templateExpressionToString($L)" , VueGWTTools . class , expression . getBody ( ) ) ; } else if ( expression . isReturnVoid ( ) ) { templateExpressionMethodBuilder . addStatement ( "$L" , expression . getBody ( ) ) ; } else if ( expression . isReturnAny ( ) ) { templateExpressionMethodBuilder . addStatement ( "return $T.asAny($L)" , Js . class , expression . getBody ( ) ) ; } else if ( expression . isShouldCast ( ) ) { templateExpressionMethodBuilder . addStatement ( "return ($T) ($L)" , expression . getType ( ) , expression . getBody ( ) ) ; } else { templateExpressionMethodBuilder . addStatement ( "return $L" , expression . getBody ( ) ) ; } exposedTypeGenerator . getClassBuilder ( ) . addMethod ( templateExpressionMethodBuilder . build ( ) ) ; exposedTypeGenerator . addMethodToProto ( expression . getId ( ) ) ; }
Generate the Java method for an expression in the Template