Skip to content

Commit

Permalink
Cosmetic changes
Browse files Browse the repository at this point in the history
- names of method's parameters were slightly misleading (considering the usage of the method)
  • Loading branch information
bafco authored and jharting committed Jul 9, 2014
1 parent b73c436 commit bc5701f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ private boolean matches(Class<?> requiredType, Class<?> beanType) {
* A parameterized bean type is considered assignable to a raw required type if the raw types
* are identical and all type parameters of the bean type are either unbounded type variables or
* java.lang.Object.
*
* <p>
* A raw bean type is considered assignable to a parameterized required type if the raw types are
* identical and all type parameters of the required type are either unbounded type variables or
* java.lang.Object.
*
*/
private boolean matches(Class<?> requiredType, ParameterizedType beanType) {
if (!requiredType.equals(Reflections.getRawType(beanType))) {
private boolean matches(Class<?> type1, ParameterizedType type2) {
if (!type1.equals(Reflections.getRawType(type2))) {
return false;
}
return Types.isArrayOfUnboundedTypeVariablesOrObjects(beanType.getActualTypeArguments());
return Types.isArrayOfUnboundedTypeVariablesOrObjects(type2.getActualTypeArguments());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ private static boolean isAssignableFrom(GenericArrayType type1, ParameterizedTyp

private static boolean isAssignableFrom(GenericArrayType type1, TypeVariable<?> type2) {
/*
* JLS does not allow array types to be used as bounds
* JLS does not allow array types to be used as bounds of type variables
*/
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void testArrayBoxing() {
@Test
public <T1 extends Number, T2 extends T1> void testTypeVariableWithTypeVariableBound() {
Assert.assertTrue("List<T2 extends T1 extends Number> should be assignable to List<Number>", getRules().matches(new TypeLiteral<List<Number>>() {}.getType(), new TypeLiteral<List<T2>>() {}.getType()));
Assert.assertFalse("List<T2 extends T1 extends Number> should not be assignable List<Runnable>", getRules().matches(new TypeLiteral<List<Runnable>>() {}.getType(), new TypeLiteral<List<T2>>() {}.getType()));
Assert.assertFalse("List<T2 extends T1 extends Number> should not be assignable to List<Runnable>", getRules().matches(new TypeLiteral<List<Runnable>>() {}.getType(), new TypeLiteral<List<T2>>() {}.getType()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ public <T, S extends Integer> void testArrays() {
Assert.assertTrue("int[][] should be assignable to int[][]", getRules().matches(new int[0][].getClass(), new int[0][].getClass()));
Assert.assertTrue("Integer[][] should be assignable to Integer[][]", getRules().matches(new Integer[0][].getClass(), new Integer[0][].getClass()));
Assert.assertTrue("Integer[][] should be assignable to Number[][]", getRules().matches(new Number[0][].getClass(), new Integer[0][].getClass()));
Assert.assertTrue("Integer[][] should be assignable to Number[][]", getRules().matches(new TypeLiteral<T[]>() {}.getType(), new Integer[0][].getClass()));
Assert.assertTrue("Integer[][] should be assignable to Number[][]", getRules().matches(new TypeLiteral<T[][]>() {}.getType(), new Integer[0][].getClass()));
Assert.assertFalse("Integer[][] should be assignable to Number[][]", getRules().matches(new TypeLiteral<S[]>() {}.getType(), new Integer[0][].getClass()));
Assert.assertTrue("Integer[][] should be assignable to Number[][]", getRules().matches(new TypeLiteral<S[][]>() {}.getType(), new Integer[0][].getClass()));
Assert.assertFalse("Integer[][] should be assignable to Number[][]", getRules().matches(new TypeLiteral<S[][]>() {}.getType(), new Number[0][].getClass()));
Assert.assertTrue("Integer[][] should be assignable to T[]", getRules().matches(new TypeLiteral<T[]>() {}.getType(), new Integer[0][].getClass()));
Assert.assertTrue("Integer[][] should be assignable to T[][]", getRules().matches(new TypeLiteral<T[][]>() {}.getType(), new Integer[0][].getClass()));
Assert.assertFalse("Integer[][] should not be assignable to S[] where S extends Integer", getRules().matches(new TypeLiteral<S[]>() {}.getType(), new Integer[0][].getClass()));
Assert.assertTrue("Integer[][] should be assignable to S[][] where S extends Integer", getRules().matches(new TypeLiteral<S[][]>() {}.getType(), new Integer[0][].getClass()));
Assert.assertFalse("Number[][] should not be assignable to S[][] where S extends Integer", getRules().matches(new TypeLiteral<S[][]>() {}.getType(), new Number[0][].getClass()));
}

@Test
Expand All @@ -243,6 +243,6 @@ public void testArrayBoxing() {
@Test
public <T1 extends Number, T2 extends T1> void testTypeVariableWithTypeVariableBound() {
Assert.assertTrue("Number should be assignable to T2 extends T1 extends Number", getRules().matches(new TypeLiteral<T2>() {}.getType(), Number.class));
Assert.assertFalse("Number should not be assignable to T2 extends T1 extends Number", getRules().matches(new TypeLiteral<T2>() {}.getType(), Runnable.class));
Assert.assertFalse("Number should not be assignable to T2 extends T1 extends Runnable", getRules().matches(new TypeLiteral<T2>() {}.getType(), Runnable.class));
}
}

0 comments on commit bc5701f

Please sign in to comment.