boolean (PsiExpression expression, String classToConstruct) { if (!(expression instanceof PsiMethodCallExpression methodCallExpression)) { return false; } final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression(); final PsiExpression qualifierExpression = methodExpression.getQualifierExpression(); if (qualifierExpression == null) { return false; } boolean shouldReplace = switch (classToConstruct) { case CommonClassNames.JAVA_LANG_INTEGER -> MethodCallUtils.isCallToMethod(methodCallExpression, CommonClassNames.JAVA_LANG_INTEGER, PsiTypes.intType(), "intValue"); case CommonClassNames.JAVA_LANG_SHORT -> MethodCallUtils.isCallToMethod(methodCallExpression, CommonClassNames.JAVA_LANG_SHORT, PsiTypes.shortType(), "shortValue"); case CommonClassNames.JAVA_LANG_BYTE -> MethodCallUtils.isCallToMethod(methodCallExpression, CommonClassNames.JAVA_LANG_BYTE, PsiTypes.byteType(), "byteValue"); case CommonClassNames.JAVA_LANG_CHARACTER -> MethodCallUtils.isCallToMethod(methodCallExpression, CommonClassNames.JAVA_LANG_CHARACTER, PsiTypes.charType(), "charValue"); case CommonClassNames.JAVA_LANG_LONG -> MethodCallUtils.isCallToMethod(methodCallExpression, CommonClassNames.JAVA_LANG_LONG, PsiTypes.longType(), "longValue"); case CommonClassNames.JAVA_LANG_FLOAT -> MethodCallUtils.isCallToMethod(methodCallExpression, CommonClassNames.JAVA_LANG_FLOAT, PsiTypes.floatType(), "floatValue"); case CommonClassNames.JAVA_LANG_DOUBLE -> MethodCallUtils.isCallToMethod(methodCallExpression, CommonClassNames.JAVA_LANG_DOUBLE, PsiTypes.doubleType(), "doubleValue"); default -> false; }; if (shouldReplace) { expression.replace(qualifierExpression); return true; } return false; }