ExpressionUtils { public static IdentifierTree extractIdentifier(AssignmentExpressionTree tree) { Optional<IdentifierTree> identifier = extractIdentifier(tree.variable()); if (identifier.isPresent()) { return identifier.get(); } throw new IllegalArgumentException("Can not extract identifier."); } private  ExpressionUtils(); static boolean isSimpleAssignment(AssignmentExpressionTree tree); static boolean isSelectOnThisOrSuper(AssignmentExpressionTree tree); static boolean isSelectOnThisOrSuper(MemberSelectExpressionTree tree); static IdentifierTree extractIdentifier(AssignmentExpressionTree tree); static Optional<Symbol> extractIdentifierSymbol(ExpressionTree tree); static boolean isInvocationOnVariable(MethodInvocationTree mit, @Nullable Symbol variable, boolean defaultReturn); static ExpressionTree skipParentheses(ExpressionTree tree); static boolean isNullLiteral(ExpressionTree tree); static boolean isSecuringByte(ExpressionTree expression); static IdentifierTree methodName(MethodInvocationTree mit); @CheckForNull static MethodTree getEnclosingMethod(ExpressionTree expr); static Optional<Symbol> getAssignedSymbol(ExpressionTree exp); static boolean isThis(ExpressionTree expression); @CheckForNull static Object resolveAsConstant(ExpressionTree tree);  }
@Test void test_cannot_extract_identifier() throws Exception { File file = new File("src/test/files/model/ExpressionUtilsTest.java"); CompilationUnitTree tree = JParserTestUtils.parse(file); MethodTree methodTree = (MethodTree) ((ClassTree) tree.types().get(0)).members().get(1); List<AssignmentExpressionTree> assignments = findAssignmentExpressionTrees(methodTree); AssignmentExpressionTree assignment = assignments.get(4); assertThrows(IllegalArgumentException.class, () -> ExpressionUtils.extractIdentifier(assignment)); }