use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.
the class VisitorMapTest method visitorMapContainsKey.
@Test
public void visitorMapContainsKey() {
CompilationUnit x1 = JavaParser.parse("class X{}");
Map<CompilationUnit, Integer> map = new VisitorMap<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
map.put(x1, 1);
assertTrue(map.containsKey(x1));
}
use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.
the class VisitorMapTest method visitorMapPutAll.
@Test
public void visitorMapPutAll() {
CompilationUnit x1 = JavaParser.parse("class X{}");
CompilationUnit x2 = JavaParser.parse("class Y{}");
Map<CompilationUnit, Integer> map = new HashMap<>();
map.put(x1, 1);
map.put(x2, 2);
Map<CompilationUnit, Integer> visitorMap = new VisitorMap<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
visitorMap.putAll(map);
assertEquals(2, visitorMap.size());
}
use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.
the class VisitorMapTest method visitorMapGet.
@Test
public void visitorMapGet() {
CompilationUnit x1 = JavaParser.parse("class X{}");
Map<CompilationUnit, Integer> map = new VisitorMap<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
map.put(x1, 1);
assertEquals(1, (int) map.get(x1));
}
use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.
the class VisitorListTest method visitorListIterator.
@Test
public void visitorListIterator() {
VisitorList<CompilationUnit> list = new VisitorList<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
CompilationUnit x1 = JavaParser.parse("class X{}");
list.add(x1);
CompilationUnit x2 = JavaParser.parse("class X{}");
list.add(x2);
Iterator<CompilationUnit> itr = list.iterator();
assertEquals(x1, itr.next());
itr.remove();
assertTrue(list.size() == 1);
assertEquals(x2, itr.next());
itr.remove();
assertTrue(list.size() == 0);
}
use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.
the class VisitorListTest method visitorListRemove.
@Test
public void visitorListRemove() {
CompilationUnit x1 = JavaParser.parse("class X{}");
VisitorList<CompilationUnit> list = new VisitorList<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
list.add(x1);
assertTrue(list.remove(x1));
}
Aggregations