code: public static UriTemplateMatcher create(Stream<? extends ImmutableFunctionalTerm> targetAtomStream,
                                              TermFactory termFactory) {
          Set<String> templateStrings = new HashSet<>();
  
          UriTemplateMatcher uriTemplateMatcher = new UriTemplateMatcher(termFactory);
  
          ImmutableList<? extends ImmutableFunctionalTerm> targetAtoms = targetAtomStream.collect(ImmutableCollectors.toList());
  
          for (ImmutableFunctionalTerm fun : targetAtoms) {
  
              // Collecting URI templates and making pattern matchers for them.
              if (!(fun.getFunctionSymbol() instanceof URITemplatePredicate)) {
                  continue;
              }
              /*
  			 * This is a URI function, so it can generate pattern matchers
  			 * for the URIs. We have two cases, one where the arity is 1,
  			 * and there is a constant/variable. The second case is
  			 * where the first element is a string template of the URI, and
  			 * the rest of the terms are variables/constants
  			 */
              if (fun.getTerms().size() == 1) {
  				/*
  				 * URI without template, we get it directly from the column
  				 * of the table, and the function is only f(x)
  				 */
                  if (templateStrings.contains("(.+)")) {
                      continue;
                  }
  
                  ImmutableFunctionalTerm templateFunction = termFactory.getImmutableUriTemplate(termFactory.getVariable("x"));
                  Pattern matcher = Pattern.compile("(.+)");
                  uriTemplateMatcher.uriTemplateMatcher.put(matcher, templateFunction);
                  templateStrings.add("(.+)");
              } else {
                  ValueConstant template = (ValueConstant) fun.getTerms().get(0);
                  String templateString = template.getValue();
                  templateString = templateString.replace("{}", "(.+)");
  
                  if (templateStrings.contains(templateString)) {
                      continue;
                  }
  
                  Pattern matcher = Pattern.compile(templateString);
                  uriTemplateMatcher.uriTemplateMatcher.put(matcher, fun);
                  templateStrings.add(templateString);
  
              }
          }
          return uriTemplateMatcher;
      }
docs: TODO: refactor using streaming.