@SuppressWarnings("unchecked")
    private <T extends GifBlock> List<T> findAllBlocks(final List<GifBlock> blocks, final int code) {
        final List<T> filteredBlocks = new ArrayList<>();
        for (final GifBlock gifBlock : blocks) {
            if (gifBlock.blockCode == code) {
                filteredBlocks.add((T) gifBlock);
            }
        }
        return filteredBlocks;
    }
See {@link GifImageParser#readBlocks} for reference how the blocks are created. They should match the code we are giving here, returning the correct
class type. Internal only.
src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java