use of com.github.javaparser.resolution.types.ResolvedArrayType in project javaparser by javaparser.
the class ArrayTypeTest method testReplaceParam.
@Test
public void testReplaceParam() {
assertTrue(arrayOfBooleans == arrayOfBooleans.replaceTypeVariables(tpA, OBJECT));
assertTrue(arrayOfStrings == arrayOfStrings.replaceTypeVariables(tpA, OBJECT));
assertEquals(arrayOfListOfStrings, arrayOfListOfStrings.replaceTypeVariables(tpA, OBJECT));
ResolvedArrayType arrayOfListOfObjects = new ResolvedArrayType(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(List.class, typeSolver), ImmutableList.of(OBJECT), typeSolver));
assertEquals(true, arrayOfListOfA.replaceTypeVariables(tpA, OBJECT).isArray());
assertEquals(ImmutableList.of(OBJECT), arrayOfListOfA.replaceTypeVariables(tpA, OBJECT).asArrayType().getComponentType().asReferenceType().typeParametersValues());
assertEquals(new ReflectionInterfaceDeclaration(List.class, typeSolver), arrayOfListOfA.replaceTypeVariables(tpA, OBJECT).asArrayType().getComponentType().asReferenceType().getTypeDeclaration());
assertEquals(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(List.class, typeSolver), ImmutableList.of(OBJECT), typeSolver), arrayOfListOfA.replaceTypeVariables(tpA, OBJECT).asArrayType().getComponentType());
assertEquals(arrayOfListOfObjects, arrayOfListOfA.replaceTypeVariables(tpA, OBJECT));
assertEquals(arrayOfListOfStrings, arrayOfListOfA.replaceTypeVariables(tpA, STRING));
assertTrue(arrayOfListOfA != arrayOfListOfA.replaceTypeVariables(tpA, OBJECT));
}
use of com.github.javaparser.resolution.types.ResolvedArrayType in project javaparser by javaparser.
the class ArrayTypeTest 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);
arrayOfStrings = new ResolvedArrayType(STRING);
tpA = ResolvedTypeParameterDeclaration.onType("A", "foo.Bar", Collections.emptyList());
arrayOfListOfA = new ResolvedArrayType(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(List.class, typeSolver), ImmutableList.of(new ResolvedTypeVariable(tpA)), typeSolver));
arrayOfListOfStrings = new ResolvedArrayType(new ReferenceTypeImpl(new ReflectionInterfaceDeclaration(List.class, typeSolver), ImmutableList.of(new ReferenceTypeImpl(new ReflectionClassDeclaration(String.class, typeSolver), typeSolver)), typeSolver));
}
use of com.github.javaparser.resolution.types.ResolvedArrayType in project javaparser by javaparser.
the class NullTypeTest 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));
}
use of com.github.javaparser.resolution.types.ResolvedArrayType in project javaparser by javaparser.
the class VoidTypeTest 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));
}
use of com.github.javaparser.resolution.types.ResolvedArrayType in project javaparser by javaparser.
the class ConstructorResolutionLogic method groupVariadicParamValues.
private static List<ResolvedType> groupVariadicParamValues(List<ResolvedType> argumentsTypes, int startVariadic, ResolvedType variadicType) {
List<ResolvedType> res = new ArrayList<>(argumentsTypes.subList(0, startVariadic));
List<ResolvedType> variadicValues = argumentsTypes.subList(startVariadic, argumentsTypes.size());
if (variadicValues.isEmpty()) {
// TODO if there are no variadic values we should default to the bound of the formal type
res.add(variadicType);
} else {
ResolvedType componentType = findCommonType(variadicValues);
res.add(new ResolvedArrayType(componentType));
}
return res;
}
Aggregations