code: public String getPrefixPreamble(final PrefixMapping mapping) {
          return mapping.getNsPrefixMap().entrySet().stream()
                  .map(e -> "PREFIX " + e.getKey() + ": <" + e.getValue() + ">").collect(joining("\n", "", "\n\n"));
      }
docs: Get a prefix preamble appropriate for a SPARQL-UPDATE query from a prefix
  mapping object
  
  @param mapping the prefix mapping
  @return prefix preamble