docs: @Override
    public BitMatrix encode(String contents,
                            BarcodeFormat format,
                            int width,
                            int height,
                            Map<EncodeHintType,?> hints) throws WriterException {
      if (contents.isEmpty()) {
        throw new IllegalArgumentException("Found empty contents");
      }
  
      if (width < 0 || height < 0) {
        throw new IllegalArgumentException("Negative size is not allowed. Input: "
                                               + width + 'x' + height);
      }
  
      int sidesMargin = getDefaultMargin();
      if (hints != null && hints.containsKey(EncodeHintType.MARGIN)) {
        sidesMargin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
      }
  
      boolean[] code = encode(contents);
      return renderResult(code, width, height, sidesMargin);
    }