Optional<PsiType> () { PsiVariable psiVariable = variableInClass; if (StringUtil.isNotEmpty(viaFieldName)) { final PsiField fieldByName = getPsiClass().findFieldByName(viaFieldName, false); if (fieldByName != null) { psiVariable = fieldByName; } } final PsiType psiVariableType = psiVariable.getType(); if (psiVariableType instanceof PsiClassReferenceType) { final PsiClass resolvedPsiVariableClass = ((PsiClassReferenceType) psiVariableType).resolve(); if (resolvedPsiVariableClass instanceof PsiTypeParameter) { return Optional.of(psiVariableType); } } return Optional.empty(); }