Search in sources :

Example 6 with ObjectIdentityEqualsVisitor

use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.

the class VisitorListTest method visitorListContains.

@Test
public void visitorListContains() {
    CompilationUnit x1 = JavaParser.parse("class X{}");
    VisitorList<CompilationUnit> list = new VisitorList<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
    list.add(x1);
    assertTrue(list.contains(x1));
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) ObjectIdentityHashCodeVisitor(com.github.javaparser.ast.visitor.ObjectIdentityHashCodeVisitor) ObjectIdentityEqualsVisitor(com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor) Test(org.junit.Test)

Example 7 with ObjectIdentityEqualsVisitor

use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.

the class VisitorListTest method visitorListRetainAll.

@Test
public void visitorListRetainAll() {
    List<CompilationUnit> list = new ArrayList<>();
    list.add(JavaParser.parse("class X{}"));
    list.add(JavaParser.parse("class X{}"));
    VisitorList<CompilationUnit> vList = new VisitorList<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
    vList.addAll(list);
    vList.add(JavaParser.parse("class X{}"));
    vList.retainAll(list);
    assertTrue(vList.size() == 2);
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) ArrayList(java.util.ArrayList) ObjectIdentityHashCodeVisitor(com.github.javaparser.ast.visitor.ObjectIdentityHashCodeVisitor) ObjectIdentityEqualsVisitor(com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor) Test(org.junit.Test)

Example 8 with ObjectIdentityEqualsVisitor

use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.

the class VisitorSetTest method visitorSetRemove.

@Test
public void visitorSetRemove() {
    CompilationUnit x1 = JavaParser.parse("class X{}");
    Set<CompilationUnit> set = new VisitorSet<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
    set.add(x1);
    assertTrue(set.remove(x1));
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) ObjectIdentityHashCodeVisitor(com.github.javaparser.ast.visitor.ObjectIdentityHashCodeVisitor) ObjectIdentityEqualsVisitor(com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor) Test(org.junit.Test)

Example 9 with ObjectIdentityEqualsVisitor

use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.

the class VisitorSetTest method visitorSetContains.

@Test
public void visitorSetContains() {
    CompilationUnit x1 = JavaParser.parse("class X{}");
    Set<CompilationUnit> set = new VisitorSet<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
    set.add(x1);
    assertTrue(set.contains(x1));
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) ObjectIdentityHashCodeVisitor(com.github.javaparser.ast.visitor.ObjectIdentityHashCodeVisitor) ObjectIdentityEqualsVisitor(com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor) Test(org.junit.Test)

Example 10 with ObjectIdentityEqualsVisitor

use of com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor in project javaparser by javaparser.

the class VisitorListTest method visitorListContainsAll.

@Test
public void visitorListContainsAll() {
    List<CompilationUnit> list = new ArrayList<>();
    list.add(JavaParser.parse("class X{}"));
    list.add(JavaParser.parse("class X{}"));
    VisitorList<CompilationUnit> vList = new VisitorList<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
    vList.addAll(list);
    assertTrue(vList.size() == 2 && vList.containsAll(list));
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) ArrayList(java.util.ArrayList) ObjectIdentityHashCodeVisitor(com.github.javaparser.ast.visitor.ObjectIdentityHashCodeVisitor) ObjectIdentityEqualsVisitor(com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor) Test(org.junit.Test)

Aggregations

CompilationUnit (com.github.javaparser.ast.CompilationUnit)24 ObjectIdentityEqualsVisitor (com.github.javaparser.ast.visitor.ObjectIdentityEqualsVisitor)24 ObjectIdentityHashCodeVisitor (com.github.javaparser.ast.visitor.ObjectIdentityHashCodeVisitor)24 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)1