@Test public void test_equivalence_list() { List<Tree> list1 = Arrays.asList(identifier("a"), integerLiteral("2")); List<Tree> list2 = Arrays.asList(identifier("a"), integerLiteral("2")); List<Tree> list3 = Arrays.asList(identifier("a"), integerLiteral("3")); List<Tree> list4 = Collections.singletonList(identifier("a")); assertThat(areEquivalent((List<Tree>) null, null)).isTrue(); assertThat(areEquivalent(list1, null)).isFalse(); assertThat(areEquivalent(null, list1)).isFalse(); assertThat(areEquivalent(list1, list1)).isTrue(); assertThat(areEquivalent(list1, list2)).isTrue(); assertThat(areEquivalent(list1, list3)).isFalse(); assertThat(areEquivalent(list1, list4)).isFalse(); }
public static boolean areEquivalent(@Nullable List<? extends Tree> first, @Nullable List<? extends Tree> second) { if (first == second) { return true; } if (first == null || second == null || first.size() != second.size()) { return false; } for (int i = 0; i < first.size(); i++) { if (!areEquivalent(first.get(i), second.get(i))) { return false; } } return true; }
SyntacticEquivalence { public static boolean areEquivalent(@Nullable List<? extends Tree> first, @Nullable List<? extends Tree> second) { if (first == second) { return true; } if (first == null || second == null || first.size() != second.size()) { return false; } for (int i = 0; i < first.size(); i++) { if (!areEquivalent(first.get(i), second.get(i))) { return false; } } return true; } }
SyntacticEquivalence { public static boolean areEquivalent(@Nullable List<? extends Tree> first, @Nullable List<? extends Tree> second) { if (first == second) { return true; } if (first == null || second == null || first.size() != second.size()) { return false; } for (int i = 0; i < first.size(); i++) { if (!areEquivalent(first.get(i), second.get(i))) { return false; } } return true; } private  SyntacticEquivalence(); }
SyntacticEquivalence { public static boolean areEquivalent(@Nullable List<? extends Tree> first, @Nullable List<? extends Tree> second) { if (first == second) { return true; } if (first == null || second == null || first.size() != second.size()) { return false; } for (int i = 0; i < first.size(); i++) { if (!areEquivalent(first.get(i), second.get(i))) { return false; } } return true; } private  SyntacticEquivalence(); static boolean areEquivalent(@Nullable List<? extends Tree> first, @Nullable List<? extends Tree> second); static boolean areEquivalent(@Nullable Tree first, @Nullable Tree second); static String getUniqueIdentifier(IdentifierTree identifier); static List<List<Tree>> findDuplicatedGroups(List<Tree> list); }
SyntacticEquivalence { public static boolean areEquivalent(@Nullable List<? extends Tree> first, @Nullable List<? extends Tree> second) { if (first == second) { return true; } if (first == null || second == null || first.size() != second.size()) { return false; } for (int i = 0; i < first.size(); i++) { if (!areEquivalent(first.get(i), second.get(i))) { return false; } } return true; } private  SyntacticEquivalence(); static boolean areEquivalent(@Nullable List<? extends Tree> first, @Nullable List<? extends Tree> second); static boolean areEquivalent(@Nullable Tree first, @Nullable Tree second); static String getUniqueIdentifier(IdentifierTree identifier); static List<List<Tree>> findDuplicatedGroups(List<Tree> list);  }