PsiType (PsiType type) { PsiClass aClass = PsiUtil.resolveClassInClassTypeOnly(type); if(aClass == null) return null; String className = aClass.getQualifiedName(); if(className == null) return null; return switch (className) { case OPTIONAL_INT -> PsiTypes.intType(); case OPTIONAL_LONG -> PsiTypes.longType(); case OPTIONAL_DOUBLE -> PsiTypes.doubleType(); case JAVA_UTIL_OPTIONAL, GUAVA_OPTIONAL -> { PsiType[] parameters = ((PsiClassType)type).getParameters(); if (parameters.length != 1) yield null; PsiType streamType = parameters[0]; if (streamType instanceof PsiCapturedWildcardType) { streamType = ((PsiCapturedWildcardType)streamType).getUpperBound(); } yield streamType; } default -> null; }; }