use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.
the class VisitorListTest method visitorListListIterator.
@Test
public void visitorListListIterator() {
VisitorList<CompilationUnit> list = new VisitorList<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
list.add(JavaParser.parse("class X{}"));
list.add(JavaParser.parse("class X{}"));
CompilationUnit x1 = JavaParser.parse("class X{}");
list.add(x1);
CompilationUnit x2 = JavaParser.parse("class X{}");
list.add(x2);
Iterator<CompilationUnit> itr = list.listIterator(2);
assertEquals(x1, itr.next());
itr.remove();
assertTrue(list.size() == 3);
assertEquals(x2, itr.next());
itr.remove();
assertTrue(list.size() == 2);
}
use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.
the class VisitorSetTest method visitorSetContainsAll.
@Test
public void visitorSetContainsAll() {
List<CompilationUnit> list = new ArrayList<>();
list.add(JavaParser.parse("class X{}"));
list.add(JavaParser.parse("class X{}"));
Set<CompilationUnit> set = new VisitorSet<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
set.addAll(list);
assertTrue(set.size() == 2 && set.containsAll(list));
}
use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.
the class VisitorSetTest method visitorSetRetainAll.
@Test
public void visitorSetRetainAll() {
List<CompilationUnit> list = new ArrayList<>();
list.add(JavaParser.parse("class X{}"));
list.add(JavaParser.parse("class X{}"));
Set<CompilationUnit> set = new VisitorSet<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
set.addAll(list);
set.add(JavaParser.parse("class X{}"));
set.retainAll(list);
assertTrue(set.size() == 2);
}
use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.
the class VisitorSetTest method visitorSetIterator.
@Test
public void visitorSetIterator() {
Set<CompilationUnit> set = new VisitorSet<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
CompilationUnit x1 = JavaParser.parse("class X{}");
set.add(x1);
CompilationUnit x2 = JavaParser.parse("class X{}");
set.add(x2);
Iterator<CompilationUnit> itr = set.iterator();
assertEquals(x1, itr.next());
itr.remove();
assertTrue(set.size() == 1);
assertEquals(x2, itr.next());
itr.remove();
assertTrue(set.size() == 0);
}
use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.
the class VisitorSetTest method visitorSetRemoveAll.
@Test
public void visitorSetRemoveAll() {
List<CompilationUnit> list = new ArrayList<>();
list.add(JavaParser.parse("class X{}"));
list.add(JavaParser.parse("class X{}"));
Set<CompilationUnit> set = new VisitorSet<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
set.addAll(list);
set.removeAll(list);
assertTrue(set.size() == 0);
}
Aggregations