@Test public void testIsAssignable() throws Exception { assertThat(Types.isAssignable(int.class, Integer.class), is(true)); assertThat(Types.isAssignable(Integer.class, Integer.class), is(true)); assertThat(Types.isAssignable(Integer.class, int.class), is(true)); assertThat(Types.isAssignable(int.class, int.class), is(true)); assertThat(Types.isAssignable(int.class, long.class), is(false)); assertThat(Types.isAssignable(Integer.class, Long.class), is(false)); assertThat(Types.isAssignable(A.class, B.class), is(true)); assertThat(Types.isAssignable(A.class, A.class), is(true)); assertThat(Types.isAssignable(B.class, B.class), is(true)); assertThat(Types.isAssignable(B.class, A.class), is(false)); }
public static boolean isAssignable(Class<?> lhsType, Class<?> rhsType) { if (lhsType.isAssignableFrom(rhsType)) { return true; } return lhsType.isPrimitive() ? lhsType.equals(Primitives.unwrap(rhsType)) : lhsType.isAssignableFrom(Primitives.wrap(rhsType)); }
Types { public static boolean isAssignable(Class<?> lhsType, Class<?> rhsType) { if (lhsType.isAssignableFrom(rhsType)) { return true; } return lhsType.isPrimitive() ? lhsType.equals(Primitives.unwrap(rhsType)) : lhsType.isAssignableFrom(Primitives.wrap(rhsType)); } }
Types { public static boolean isAssignable(Class<?> lhsType, Class<?> rhsType) { if (lhsType.isAssignableFrom(rhsType)) { return true; } return lhsType.isPrimitive() ? lhsType.equals(Primitives.unwrap(rhsType)) : lhsType.isAssignableFrom(Primitives.wrap(rhsType)); } private  Types(); }
Types { public static boolean isAssignable(Class<?> lhsType, Class<?> rhsType) { if (lhsType.isAssignableFrom(rhsType)) { return true; } return lhsType.isPrimitive() ? lhsType.equals(Primitives.unwrap(rhsType)) : lhsType.isAssignableFrom(Primitives.wrap(rhsType)); } private  Types(); static boolean isAssignable(Class<?> lhsType, Class<?> rhsType); static boolean equals(Class<?> lhsType, Class<?> rhsType); }
Types { public static boolean isAssignable(Class<?> lhsType, Class<?> rhsType) { if (lhsType.isAssignableFrom(rhsType)) { return true; } return lhsType.isPrimitive() ? lhsType.equals(Primitives.unwrap(rhsType)) : lhsType.isAssignableFrom(Primitives.wrap(rhsType)); } private  Types(); static boolean isAssignable(Class<?> lhsType, Class<?> rhsType); static boolean equals(Class<?> lhsType, Class<?> rhsType);  }