public String expand(Map<String, ?> variables) {
    if (variables == null) {
      throw new IllegalArgumentException("variable map is required.");
    }

    /* resolve all expressions within the template */
    StringBuilder resolved = null;
    for (TemplateChunk chunk : this.templateChunks) {
      String expanded;
      if (chunk instanceof Expression) {
        expanded = this.resolveExpression((Expression) chunk, variables);
      } else {
        /* chunk is a literal value */
        expanded = chunk.getValue();
      }
      if (expanded == null) {
        continue;
      }

      /* append it to the result */
      if (resolved == null) {
        resolved = new StringBuilder();
      }
      resolved.append(expanded);
    }

    if (resolved == null) {
      /* entire template is unresolved */
      return null;
    }

    return resolved.toString();
  }
Expand the template.

@param variables containing the values for expansion.
@return a fully qualified URI with the variables expanded.
core/src/main/java/feign/template/Template.java