private void addInjectedVariable ( VariableElement element , String fieldName ) { TypeName typeName = resolveVariableTypeName ( element , messager ) ; // Create field FieldSpec . Builder fieldBuilder = FieldSpec . builder ( typeName , fieldName , Modifier . PUBLIC ) ; // Copy field annotations element . getAnnotationMirrors ( ) . stream ( ) . map ( AnnotationSpec :: get ) . forEach ( fieldBuilder :: addAnnotation ) ; // If the variable element is a method parameter, it might not have the Inject annotation if ( ! hasInjectAnnotation ( element ) ) { fieldBuilder . addAnnotation ( Inject . class ) ; } // And add field builder . addField ( fieldBuilder . build ( ) ) ; }
Add an injected variable to our component