@Nullable
  public static Decompressor getCompressorInstance(@NonNull Context context, @NonNull File file) {
    Decompressor decompressor;
    String type = getExtension(file.getPath());

    if (isZip(type)) {
      decompressor = new ZipDecompressor(context);
    } else if (BuildConfig.FLAVOR.equals("play") && isRar(type)) {
      decompressor = new RarDecompressor(context);
    } else if (isTar(type)) {
      decompressor = new TarDecompressor(context);
    } else if (isGzippedTar(type)) {
      decompressor = new TarGzDecompressor(context);
    } else if (isBzippedTar(type)) {
      decompressor = new TarBzip2Decompressor(context);
    } else if (isXzippedTar(type)) {
      decompressor = new TarXzDecompressor(context);
    } else if (isLzippedTar(type)) {
      decompressor = new TarLzmaDecompressor(context);
    } else if (is7zip(type)) {
      decompressor = new SevenZipDecompressor(context);
    } else if (isXz(type) || isLzma(type) || isGzip(type) || isBzip2(type)) {
      // These 4 types are only compressing one single file.
      // Hence invoking this UnknownCompressedFileDecompressor which only returns the filename
      // without the compression extension
      decompressor = new UnknownCompressedFileDecompressor(context);
    } else {
      if (BuildConfig.DEBUG) {
        throw new IllegalArgumentException("The compressed file has no way of opening it: " + file);
      }

      LOG.error("The compressed file has no way of opening it: " + file);
      decompressor = null;
    }

    if (decompressor != null) {
      decompressor.setFilePath(file.getPath());
    }

    return decompressor;
  }
@Test
  public void getCompressorInstance() {
    File file = new File("/test/test.zip"); // .zip used by ZipDecompressor
    Decompressor result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), ZipDecompressor.class);
    file = new File("/test/test.jar"); // .jar used by ZipDecompressor
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), ZipDecompressor.class);
    file = new File("/test/test.apk"); // .apk used by ZipDecompressor
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), ZipDecompressor.class);
    file = new File("/test/test.tar"); // .tar used by TarDecompressor
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), TarDecompressor.class);
    file = new File("/test/test.tar.gz"); // .tar.gz used by GzipDecompressor
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), TarGzDecompressor.class);
    file = new File("/test/test.tgz"); // .tar.gz used by GzipDecompressor
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), TarGzDecompressor.class);
    if (BuildConfig.FLAVOR == "play") {
      file = new File("/test/test.rar"); // .rar used by RarDecompressor
      result = CompressedHelper.getCompressorInstance(context, file);
      assertEquals(result.getClass(), RarDecompressor.class);
    }
    file = new File("/test/test.tar.bz2"); // .tar.bz2 used by TarBzip2Decompressor
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), TarBzip2Decompressor.class);
    file = new File("/test/test.tbz"); // .tbz used by TarBzip2Decompressor
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), TarBzip2Decompressor.class);
    file = new File("/test/test.7z"); // Can't use 7zip
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), SevenZipDecompressor.class);
    file = new File("/test/test.tar.xz"); // .tar.xz used by TarXzDecompressor
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), TarXzDecompressor.class);
    file = new File("/test/test.tar.lzma"); // .tar.lzma used by TarLzmaDecompressor
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), TarLzmaDecompressor.class);
    file = new File("/test/test.txt.gz"); // .gz used by UnknownCompressedFileDecompressor
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), UnknownCompressedFileDecompressor.class);
    file = new File("/test/test.txt.bz2"); // .bz2 used by UnknownCompressedFileDecompressor
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), UnknownCompressedFileDecompressor.class);
    file = new File("/test/test.txt.lzma"); // .lzma used by UnknownCompressedFileDecompressor
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), UnknownCompressedFileDecompressor.class);
    file = new File("/test/test.txt.xz"); // .xz used by UnknownCompressedFileDecompressor
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), UnknownCompressedFileDecompressor.class);
  }