code: static int getRecommendedMinimumErrorCorrectionLevel(int n) throws WriterException {
      if (n <= 0) {
        throw new IllegalArgumentException("n must be > 0");
      }
      if (n <= 40) {
        return 2;
      }
      if (n <= 160) {
        return 3;
      }
      if (n <= 320) {
        return 4;
      }
      if (n <= 863) {
        return 5;
      }
      throw new WriterException("No recommendation possible");
    }
docs: Returns the recommended minimum error correction level as described in annex E of
  ISO/IEC 15438:2001(E).
  
  @param n the number of data codewords
  @return the recommended minimum error correction level