return wildcardType().withUpperBounds(unrollBounds(typeArguments, wild.getUpperBounds())) .withLowerBounds(unrollBounds(typeArguments, wild.getLowerBounds())).build();
@Test public void testWildcardType() throws Exception { final WildcardType simpleWildcard = TypeUtils.wildcardType().withUpperBounds(String.class).build(); final Field cClass = AClass.class.getField("cClass"); assertTrue(TypeUtils.equals(((ParameterizedType) cClass.getGenericType()).getActualTypeArguments()[0], simpleWildcard)); assertEquals(String.format("? extends %s", String.class.getName()), TypeUtils.toString(simpleWildcard)); assertEquals(String.format("? extends %s", String.class.getName()), simpleWildcard.toString()); }
@Test public void testGenericArrayType() throws Exception { final Type expected = getClass().getField("intWildcardComparable").getGenericType(); final GenericArrayType actual = TypeUtils.genericArrayType(TypeUtils.parameterize(Comparable.class, TypeUtils.wildcardType() .withUpperBounds(Integer.class).build())); assertTrue(TypeUtils.equals(expected, actual)); assertEquals("java.lang.Comparable<? extends java.lang.Integer>[]", actual.toString()); }
return wildcardType().withUpperBounds(unrollBounds(typeArguments, wild.getUpperBounds())) .withLowerBounds(unrollBounds(typeArguments, wild.getLowerBounds())).build();
return wildcardType().withUpperBounds(unrollBounds(typeArguments, wild.getUpperBounds())) .withLowerBounds(unrollBounds(typeArguments, wild.getLowerBounds())).build();
return wildcardType().withUpperBounds(unrollBounds(typeArguments, wild.getUpperBounds())) .withLowerBounds(unrollBounds(typeArguments, wild.getLowerBounds())).build();
@Test public void testUnboundedWildcardType() { final WildcardType unbounded = TypeUtils.wildcardType().withLowerBounds((Type) null).withUpperBounds().build(); assertTrue(TypeUtils.equals(TypeUtils.WILDCARD_ALL, unbounded)); assertArrayEquals(new Type[] { Object.class }, TypeUtils.getImplicitUpperBounds(unbounded)); assertArrayEquals(new Type[] { null }, TypeUtils.getImplicitLowerBounds(unbounded)); assertEquals("?", TypeUtils.toString(unbounded)); assertEquals("?", unbounded.toString()); }