LombokLightFieldBuilder (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { // called only after validation succeeded final Project project = psiClass.getProject(); final PsiManager manager = psiClass.getContainingFile().getManager(); final PsiElementFactory psiElementFactory = JavaPsiFacade.getElementFactory(project); String loggerType = getLoggerType(psiClass); if (loggerType == null) { throw new IllegalStateException("Invalid custom log declaration."); // validated } final PsiType psiLoggerType = psiElementFactory.createTypeFromText(loggerType, psiClass); LombokLightFieldBuilder loggerField = new LombokLightFieldBuilder(manager, getLoggerName(psiClass), psiLoggerType) .withContainingClass(psiClass) .withModifier(PsiModifier.FINAL) .withModifier(PsiModifier.PRIVATE) .withNavigationElement(psiAnnotation); if (isLoggerStatic(psiClass)) { loggerField.withModifier(PsiModifier.STATIC); } final String loggerInitializerParameters = createLoggerInitializeParameters(psiClass, psiAnnotation); final String initializerText = String.format(getLoggerInitializer(psiClass), loggerInitializerParameters); final PsiExpression initializer = psiElementFactory.createExpressionFromText(initializerText, psiClass); loggerField.setInitializer(initializer); return loggerField; }