ExpressionToConstantComparison (PsiExpression candidate, PsiExpression constant, PsiExpression nonConstant) { String constantValue = tryCast(ExpressionUtils.computeConstantExpression(constant), String.class); if (constantValue != null) { return new ExpressionToConstantComparison(candidate, nonConstant, constant, constantValue); } PsiReferenceExpression ref = tryCast(PsiUtil.skipParenthesizedExprDown(constant), PsiReferenceExpression.class); if (ref != null) { PsiEnumConstant enumConstant = tryCast(ref.resolve(), PsiEnumConstant.class); if (enumConstant != null) { return new ExpressionToConstantComparison(candidate, nonConstant, ref, enumConstant.getName()); } } return null; }