APISonar


java.util.ArrayList.getClass

> java > util > ArrayList > getClass
java APIs util APIs ArrayList APIs getClass APIs

Example 1
public void whenCheckingIsAssignableFrom_shouldReturnTrueEvenIfGenericIsSpecified() throws Exception {
        ArrayList<String> stringList = new ArrayList<>();
        ArrayList<Integer> intList = new ArrayList<>();
        boolean isAssignableFrom = stringList.getClass().isAssignableFrom(intList.getClass());

        assertTrue(isAssignableFrom);
    }
Example 2
public void givenTwoGenericList_whenCheckIsAssignableFrom_thenReturnTrueDueToTypeErasure() {
        //given
        ArrayList<String> stringList = Lists.newArrayList();
        ArrayList<Integer> intList = Lists.newArrayList();

        //when
        boolean result = stringList.getClass().isAssignableFrom(intList.getClass());

        //then
        assertTrue(result);
    }
Example 3
public void appendArrayList(ArrayList list) {
    appendObject(list);
    Field entryField = getFirstNonPrimitiveField(list.getClass());
    if (entryField != null) {
      appendField(list, entryField, 1);
    }
  }
Example 4
private static boolean canAccessInternalArray(ArrayList<?> list)
    {
        return ArrayListIterate.ELEMENT_DATA_FIELD != null && list.getClass() == ArrayList.class;
    }
Example 5
public void customTransformerOverridesDefaultTransformer() {
    ArrayList<String> list = new ArrayList<>();
    list.add("a");

    BuildFileManifestPojoizer pojoizer =
        BuildFileManifestPojoizer.of()
            .addPojoTransformer(
                PojoTransformer.of(list.getClass(), obj -> ((ArrayList<String>) obj).get(0)));

    assertEquals("a", pojoizer.convertToPojo(list));
  }