Search in sources :

Example 11 with ResolvedTypeVariable

use of com.github.javaparser.resolution.types.ResolvedTypeVariable in project javaparser by javaparser.

the class PrimitiveTypeTest method setup.

@Before
public void setup() {
    typeSolver = new ReflectionTypeSolver();
    OBJECT = new ReferenceTypeImpl(new ReflectionClassDeclaration(Object.class, typeSolver), typeSolver);
    STRING = new ReferenceTypeImpl(new ReflectionClassDeclaration(String.class, typeSolver), typeSolver);
    arrayOfBooleans = new ResolvedArrayType(ResolvedPrimitiveType.BOOLEAN);
    arrayOfListOfA = new ResolvedArrayType(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(List.class, typeSolver), ImmutableList.of(new ResolvedTypeVariable(ResolvedTypeParameterDeclaration.onType("A", "foo.Bar", Collections.emptyList()))), typeSolver));
    booleanBox = new ReferenceTypeImpl(new ReflectionClassDeclaration(Boolean.class, typeSolver), typeSolver);
    characterBox = new ReferenceTypeImpl(new ReflectionClassDeclaration(Character.class, typeSolver), typeSolver);
    byteBox = new ReferenceTypeImpl(new ReflectionClassDeclaration(Byte.class, typeSolver), typeSolver);
    shortBox = new ReferenceTypeImpl(new ReflectionClassDeclaration(Short.class, typeSolver), typeSolver);
    integerBox = new ReferenceTypeImpl(new ReflectionClassDeclaration(Integer.class, typeSolver), typeSolver);
    longBox = new ReferenceTypeImpl(new ReflectionClassDeclaration(Long.class, typeSolver), typeSolver);
    floatBox = new ReferenceTypeImpl(new ReflectionClassDeclaration(Float.class, typeSolver), typeSolver);
    doubleBox = new ReferenceTypeImpl(new ReflectionClassDeclaration(Double.class, typeSolver), typeSolver);
}
Also used : ResolvedArrayType(com.github.javaparser.resolution.types.ResolvedArrayType) ResolvedTypeVariable(com.github.javaparser.resolution.types.ResolvedTypeVariable) ReflectionClassDeclaration(com.github.javaparser.symbolsolver.reflectionmodel.ReflectionClassDeclaration) ReflectionInterfaceDeclaration(com.github.javaparser.symbolsolver.reflectionmodel.ReflectionInterfaceDeclaration) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ReflectionTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver) Before(org.junit.Before)

Example 12 with ResolvedTypeVariable

use of com.github.javaparser.resolution.types.ResolvedTypeVariable in project javaparser by javaparser.

the class ReflectionClassDeclarationTest method testAllAncestors.

// /
// / Test ancestors
// /
@Test
public void testAllAncestors() {
    TypeSolver typeResolver = new ReflectionTypeSolver();
    ResolvedClassDeclaration arraylist = new ReflectionClassDeclaration(ArrayList.class, typeResolver);
    Map<String, ResolvedReferenceType> ancestors = new HashMap<>();
    arraylist.getAllAncestors().forEach(a -> ancestors.put(a.getQualifiedName(), a));
    assertEquals(9, ancestors.size());
    ResolvedTypeVariable typeVariable = new ResolvedTypeVariable(arraylist.getTypeParameters().get(0));
    assertEquals(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(RandomAccess.class, typeResolver), typeResolver), ancestors.get("java.util.RandomAccess"));
    assertEquals(new ReferenceTypeImpl(new ReflectionClassDeclaration(AbstractCollection.class, typeResolver), ImmutableList.of(typeVariable), typeResolver), ancestors.get("java.util.AbstractCollection"));
    assertEquals(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(List.class, typeResolver), ImmutableList.of(typeVariable), typeResolver), ancestors.get("java.util.List"));
    assertEquals(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(Cloneable.class, typeResolver), typeResolver), ancestors.get("java.lang.Cloneable"));
    assertEquals(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(Collection.class, typeResolver), ImmutableList.of(typeVariable), typeResolver), ancestors.get("java.util.Collection"));
    assertEquals(new ReferenceTypeImpl(new ReflectionClassDeclaration(AbstractList.class, typeResolver), ImmutableList.of(typeVariable), typeResolver), ancestors.get("java.util.AbstractList"));
    assertEquals(new ReferenceTypeImpl(new ReflectionClassDeclaration(Object.class, typeResolver), typeResolver), ancestors.get("java.lang.Object"));
    assertEquals(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(Iterable.class, typeResolver), ImmutableList.of(typeVariable), typeResolver), ancestors.get("java.lang.Iterable"));
    assertEquals(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(Serializable.class, typeResolver), typeResolver), ancestors.get("java.io.Serializable"));
}
Also used : ResolvedTypeVariable(com.github.javaparser.resolution.types.ResolvedTypeVariable) ResolvedReferenceType(com.github.javaparser.resolution.types.ResolvedReferenceType) TypeSolver(com.github.javaparser.symbolsolver.model.resolution.TypeSolver) ReflectionTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver) ReferenceTypeImpl(com.github.javaparser.symbolsolver.model.typesystem.ReferenceTypeImpl) ReflectionTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver) AbstractTest(com.github.javaparser.symbolsolver.AbstractTest) Test(org.junit.Test)

Example 13 with ResolvedTypeVariable

use of com.github.javaparser.resolution.types.ResolvedTypeVariable in project javaparser by javaparser.

the class ReflectionInterfaceDeclarationTest method testAllAncestors.

@Test
public void testAllAncestors() {
    TypeSolver typeResolver = new ReflectionTypeSolver();
    ResolvedInterfaceDeclaration list = new ReflectionInterfaceDeclaration(List.class, typeResolver);
    Map<String, ResolvedReferenceType> ancestors = new HashMap<>();
    list.getAllAncestors().forEach(a -> ancestors.put(a.getQualifiedName(), a));
    assertEquals(3, ancestors.size());
    ResolvedTypeVariable typeVariable = new ResolvedTypeVariable(list.getTypeParameters().get(0));
    assertEquals(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(Collection.class, typeResolver), ImmutableList.of(typeVariable), typeResolver), ancestors.get("java.util.Collection"));
    assertEquals(new ReferenceTypeImpl(new ReflectionClassDeclaration(Object.class, typeResolver), typeResolver), ancestors.get("java.lang.Object"));
    assertEquals(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(Iterable.class, typeResolver), ImmutableList.of(typeVariable), typeResolver), ancestors.get("java.lang.Iterable"));
}
Also used : ResolvedTypeVariable(com.github.javaparser.resolution.types.ResolvedTypeVariable) ResolvedReferenceType(com.github.javaparser.resolution.types.ResolvedReferenceType) HashMap(java.util.HashMap) TypeSolver(com.github.javaparser.symbolsolver.model.resolution.TypeSolver) ReflectionTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver) ReferenceTypeImpl(com.github.javaparser.symbolsolver.model.typesystem.ReferenceTypeImpl) ResolvedInterfaceDeclaration(com.github.javaparser.resolution.declarations.ResolvedInterfaceDeclaration) ReflectionTypeSolver(com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver) AbstractTest(com.github.javaparser.symbolsolver.AbstractTest) Test(org.junit.Test)

Aggregations

ResolvedTypeVariable (com.github.javaparser.resolution.types.ResolvedTypeVariable)13 ReflectionTypeSolver (com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver)9 ReflectionClassDeclaration (com.github.javaparser.symbolsolver.reflectionmodel.ReflectionClassDeclaration)7 Before (org.junit.Before)7 List (java.util.List)5 ResolvedArrayType (com.github.javaparser.resolution.types.ResolvedArrayType)4 ReflectionInterfaceDeclaration (com.github.javaparser.symbolsolver.reflectionmodel.ReflectionInterfaceDeclaration)4 ImmutableList (com.google.common.collect.ImmutableList)4 ResolvedTypeParameterDeclaration (com.github.javaparser.resolution.declarations.ResolvedTypeParameterDeclaration)3 ResolvedReferenceType (com.github.javaparser.resolution.types.ResolvedReferenceType)3 TypeSolver (com.github.javaparser.symbolsolver.model.resolution.TypeSolver)3 ReferenceTypeImpl (com.github.javaparser.symbolsolver.model.typesystem.ReferenceTypeImpl)3 Test (org.junit.Test)3 ResolvedType (com.github.javaparser.resolution.types.ResolvedType)2 AbstractTest (com.github.javaparser.symbolsolver.AbstractTest)2 HashMap (java.util.HashMap)2 AccessSpecifier (com.github.javaparser.ast.AccessSpecifier)1 MethodUsage (com.github.javaparser.resolution.MethodUsage)1 ResolvedInterfaceDeclaration (com.github.javaparser.resolution.declarations.ResolvedInterfaceDeclaration)1 ResolvedReferenceTypeDeclaration (com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration)1