private void createStaticGetMethod ( TypeElement component , ClassName vueFactoryClassName , Builder vueFactoryBuilder , List < CodeBlock > staticInitParameters ) { MethodSpec . Builder getBuilder = MethodSpec . methodBuilder ( "get" ) . addModifiers ( Modifier . STATIC , Modifier . PUBLIC ) . returns ( vueFactoryClassName ) ; getBuilder . beginControlFlow ( "if ($L == null)" , INSTANCE_PROP ) ; getBuilder . addStatement ( "$L = new $T()" , INSTANCE_PROP , vueFactoryClassName ) ; if ( hasTemplate ( processingEnv , component ) ) { getBuilder . addStatement ( "$L.injectComponentCss($T.getScopedCss())" , INSTANCE_PROP , componentExposedTypeName ( component ) ) ; } getBuilder . addCode ( "$L.init(" , INSTANCE_PROP ) ; boolean isFirst = true ; for ( CodeBlock staticInitParameter : staticInitParameters ) { if ( ! isFirst ) { getBuilder . addCode ( ", " ) ; } getBuilder . addCode ( staticInitParameter ) ; isFirst = false ; } getBuilder . addCode ( ");" ) ; getBuilder . endControlFlow ( ) ; getBuilder . addStatement ( "return $L" , INSTANCE_PROP ) ; vueFactoryBuilder . addMethod ( getBuilder . build ( ) ) ; }
Create a static get method that can be used to retrieve an instance of our Factory . Factory retrieved using this method do NOT support injection .