class DefaultDeflateCompatibilityWindow {

  public Map<JreDeflateParameters, String> getSystemValues() {
    Map<JreDeflateParameters, String> result = new HashMap<JreDeflateParameters, String>();
    MessageDigest digester;
    try {
      digester = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException e) {
      throw new RuntimeException("System doesn't support SHA-256", e);
    }

    DeflateCompressor compressor = new DeflateCompressor();
    compressor.setCaching(true);  // Makes this computation lighter weight.
    boolean[] nowrapValues = {true, false};
    int[] strategies = {Deflater.DEFAULT_STRATEGY, Deflater.FILTERED, Deflater.HUFFMAN_ONLY};
    int[] levels = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    for (final boolean nowrap : nowrapValues) {
      compressor.setNowrap(nowrap);
      for (final int strategy : strategies) {
        compressor.setStrategy(strategy);
        final int[] relevantLevels;
        if (strategy == Deflater.HUFFMAN_ONLY) {
          // There is no concept of a compression level with this
          // strategy.
          relevantLevels = new int[] {1};
        } else {
          relevantLevels = levels;
        }
        for (final int level : relevantLevels) {
          compressor.setCompressionLevel(level);
          ByteArrayOutputStream buffer = new ByteArrayOutputStream();
          try {
            compressor.compress(new ByteArrayInputStream(CorpusHolder.CORPUS_INSTANCE), buffer);
          } catch (IOException e) {
            throw new RuntimeException(e); // This should never occur as it's all in-memory.
          }
          byte[] compressedData = buffer.toByteArray();
          digester.reset();
          byte[] sha256OfCompressedData = digester.digest(compressedData);
          String sha256String = hexString(sha256OfCompressedData);
          JreDeflateParameters parameters = JreDeflateParameters.of(level, strategy, nowrap);
          result.put(parameters, sha256String);
        }
      }
    }
    compressor.release();
    return result;
  }

}