code: private void type(String type) throws IOException {
      if (this.packagePrefix == null) {
        throw new IllegalStateException();
      }
  
      Matcher m = TYPE_PATTERN.matcher(type);
      int pos = 0;
      while (true) {
        boolean found = m.find(pos);
  
        // copy non-matching characters like "<"
        int typeStart = found ? m.start() : type.length();
        out.write(type, pos, typeStart - pos);
  
        if (!found) {
          break;
        }
  
        // copy a single class name, shortening it if possible
        String name = m.group(0);
        String imported;
        if ((imported = importedTypes.get(name)) != null) {
          out.write(imported);
        } else if (name.startsWith(packagePrefix)
            && name.indexOf('.', packagePrefix.length()) == -1) {
          out.write(name.substring(packagePrefix.length()));
        } else if (name.startsWith("java.lang.")) {
          out.write(name.substring("java.lang.".length()));
        } else {
          out.write(name);
        }
        pos = m.end();
      }
    }
docs: Emits a name like {@code java.lang.String} or {@code
  java.util.List<java.lang.String>}, shorting it with imports if
  possible.