code: public static Map<String, String> parseTags(final String tagString) throws IllegalArgumentException {
          // delimit by whitespace or '='
          Scanner scanner = new Scanner(tagString).useDelimiter("\\s+|=");
  
          Map<String, String> tagMap = new HashMap<String, String>();
          try {
              while (scanner.hasNext()) {
                  String tagName = scanner.next();
                  String tagValue = scanner.next();
                  tagMap.put(tagName, tagValue);
              }
          } catch (NoSuchElementException e) {
              // The tag string is corrupted.
              throw new IllegalArgumentException("Invalid tag string '" + tagString + "'");
          } finally {
              scanner.close();
          }
  
          return tagMap;
      }
docs: Convert a tag string into a tag map.
  
  @param tagString a space-delimited string of key-value pairs. For example, {@code "key1=value1 key_n=value_n"}
  @return a tag {@link Map}
  @throws IllegalArgumentException if the tag string is corrupted.