MCPcopy Index your code
hub / github.com/OpenFeign/feign / expand

Method expand

core/src/main/java/feign/template/Template.java:98–130  ·  view source on GitHub ↗

Expand the template. @param variables containing the values for expansion. @return a fully qualified URI with the variables expanded.

(Map<String, ?> variables)

Source from the content-addressed store, hash-verified

96 * @return a fully qualified URI with the variables expanded.
97 */
98 public String expand(Map<String, ?> variables) {
99 if (variables == null) {
100 throw new IllegalArgumentException("variable map is required.");
101 }
102
103 /* resolve all expressions within the template */
104 StringBuilder resolved = null;
105 for (TemplateChunk chunk : this.templateChunks) {
106 String expanded;
107 if (chunk instanceof Expression) {
108 expanded = this.resolveExpression((Expression) chunk, variables);
109 } else {
110 /* chunk is a literal value */
111 expanded = chunk.getValue();
112 }
113 if (expanded == null) {
114 continue;
115 }
116
117 /* append it to the result */
118 if (resolved == null) {
119 resolved = new StringBuilder();
120 }
121 resolved.append(expanded);
122 }
123
124 if (resolved == null) {
125 /* entire template is unresolved */
126 return null;
127 }
128
129 return resolved.toString();
130 }
131
132 protected String resolveExpression(Expression expression, Map<String, ?> variables) {
133 String resolved = null;

Callers

nothing calls this directly

Calls 4

resolveExpressionMethod · 0.95
getValueMethod · 0.65
appendMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected